@ApiStatus.Internal
  public static TreeVisitor.@NotNull Action visitPathForElementSelection(
    @NotNull TreePath path,
    Object element,
    int editorOffset,
    @NotNull StructureViewSelectVisitorState state
  ) {
    Object last = path.getLastPathComponent();
    Object userObject = unwrapNavigatable(last);
    Object value = unwrapValue(last);
    // Even if they are equal, or node.canRepresent(element), we still need to go deeper,
    // because there may be a better match down there that's not a PSI element,
    // for example, a folding region inside the class represented by the element.
    boolean isGoodMatch =
      Comparing.equal(value, element) ||
      userObject instanceof AbstractTreeNode<?> node && node.canRepresent(element) ||
      value instanceof CustomRegionTreeElement region && region.containsOffset(editorOffset);
    boolean isAncestor = isGoodMatch ||
      value instanceof PsiElement valPsi && element instanceof PsiElement elPsi && PsiTreeUtil.isAncestor(valPsi, elPsi, true);
    if (isAncestor) {
      state.updateIfBetterMatch(path, isGoodMatch);
    }
    else if (state.canUseOptimization()) {
      state.usedOptimization();
      return TreeVisitor.Action.SKIP_CHILDREN;
    }
    return TreeVisitor.Action.CONTINUE;
  }
@ApiStatus.Internal
  public static TreeVisitor.@NotNull Action visitPathForElementSelection(
    @NotNull TreePath path,
    Object element,
    int editorOffset,
    @NotNull StructureViewSelectVisitorState state
  )