Promise<TreePath> (TreePath path) { if (path == null && state.isOptimizationUsed()) { // Some structure views merge unrelated psi elements into a structure node (MarkdownStructureViewModel). // So turn off the isAncestor() optimization and retry once. state.disableOptimization(); return myAsyncTreeModel.accept(visitor).thenAsync(this); } else { TreePath adjusted = path == null ? state.getBestMatch() : path; if (path == null && adjusted != null && !state.isExactMatch() && element instanceof PsiElement) { Object minChild = findClosestPsiElement((PsiElement)element, adjusted, myAsyncTreeModel); if (minChild != null) adjusted = adjusted.pathByAddingChild(minChild); } return adjusted == null ? Promises.rejectedPromise() : action.fun(adjusted); } }