void (Object element, VirtualFile file, boolean requestFocus, Condition<? super AbstractTreeNode<?>> nonStopCondition, AsyncPromise<Object> result, @NotNull final ProgressIndicator indicator, @Nullable final Ref<Object> virtualSelectTarget, boolean isSecondAttempt) { AbstractTreeNode<?> alreadySelected = alreadySelectedNode(element); final Runnable onDone = () -> { JTree tree = getTree(); if (tree != null && requestFocus && virtualSelectTarget == null && getUi().isReady()) { tree.requestFocus(); } result.setResult(null); }; final Condition<AbstractTreeNode<?>> condition = abstractTreeNode -> result.getState() == Promise.State.PENDING && nonStopCondition.value(abstractTreeNode); if (alreadySelected == null) { expandPathTo(file, (AbstractTreeNode)getTreeStructure().getRootElement(), element, condition, indicator, virtualSelectTarget) .onSuccess(node -> { if (virtualSelectTarget == null) { select(node, onDone); } else { onDone.run(); } }) .onError(error -> { if (isSecondAttempt) { result.cancel(); } else { _select(file, file, requestFocus, nonStopCondition, result, indicator, virtualSelectTarget, true); } }); } else if (virtualSelectTarget == null) { scrollTo(alreadySelected, onDone); } else { onDone.run(); } }