code: public static DocTreePath getPath(DocTreePath path, DocTree target) {
          Objects.requireNonNull(path); //null check
          Objects.requireNonNull(target); //null check
  
          class Result extends Error {
              static final long serialVersionUID = -5942088234594905625L;
              DocTreePath path;
              Result(DocTreePath path) {
                  this.path = path;
              }
          }
  
          class PathFinder extends DocTreePathScanner<DocTreePath,DocTree> {
              @Override
              public DocTreePath scan(DocTree tree, DocTree target) {
                  if (tree == target) {
                      throw new Result(new DocTreePath(getCurrentPath(), target));
                  }
                  return super.scan(tree, target);
              }
          }
  
          if (path.getLeaf() == target) {
              return path;
          }
  
          try {
              new PathFinder().scan(path, target);
          } catch (Result result) {
              return result.path;
          }
          return null;
      }
docs: Returns a documentation tree path for a tree node within a subtree
  identified by a DocTreePath object, or {@code null} if the node is not found.
  @param path a path identifying a node within a doc comment tree
  @param target a node to be located within the given node
  @return a path identifying the target node