code: static String[] resolveFieldPath(String name, Set<String> fullyQualifiedNames) {
      // Try to resolve a local name.
      for (int i = 0; i < name.length(); i++) {
        i = name.indexOf('.', i);
        if (i == -1) i = name.length();
  
        String candidate = name.substring(0, i);
        if (fullyQualifiedNames.contains(candidate)) {
          String[] path = name.substring(i).split("\\.", -1);
          path[0] = name.substring(0, i);
          return path;
        }
      }
  
      return null;
    }
docs: Given a path like {@code a.b.c.d} and a set of paths like {@code {a.b.c, a.f.g, h.j}}, this
  returns the original path split on dots such that the first element is in the set. For the
  above example it would return the array {@code [a.b.c, d]}.
  
  <p>Typically the input path is a package name like {@code a.b}, followed by a dot and a
  sequence of field names. The first field name is an extension field; subsequent field names
  make a path within that extension.
  
  <p>Note that a single input may yield multiple possible answers, such as when package names
  and field names collide. This method prefers shorter package names though that is an
  implementation detail.