Promise<TreePath> (TreePath path) { if (myCurrentFocusPromise != result) { result.setError("rejected"); return Promises.rejectedPromise(); } else 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; return adjusted == null ? Promises.rejectedPromise() : action.fun(adjusted); } }