Promise<Object> (@NotNull Object element) { if (!(element instanceof AbstractTreeNode node)) { return Promises.rejectedPromise(); } final AsyncPromise<Object> result = new AsyncPromise<>(); final Object value = node.getValue(); final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(ObjectUtils.tryCast(value, PsiElement.class)); batch(indicator -> { final Ref<Object> target = new Ref<>(); Promise<Object> callback = _select(element, virtualFile, true, Conditions.alwaysTrue()); callback .onSuccess(it -> result.setResult(target.get())) .onError(e -> result.setError(e)); }); return result; }