TreeNodeState (final StateWorker stateWorker) { if (stateWorker.getVf() == null) return TreeNodeState.CLEAR; final TreeNodeState stateSelf = myState.get(stateWorker.getVf()); if (stateSelf != null) return stateSelf; final Ref<TreeNodeState> result = new Ref<>(); stateWorker.iterateParents(myState, (virtualFile, state) -> { if (state != null) { if (TreeNodeState.SELECTED.equals(state) || TreeNodeState.HAVE_SELECTED_ABOVE.equals(state)) { result.set(myState.putAndPass(stateWorker.getVf(), TreeNodeState.HAVE_SELECTED_ABOVE)); } return false; // exit } return true; }); if (! result.isNull()) return result.get(); for (VirtualFile selected : myState.getSelected()) { if (VfsUtilCore.isAncestor(stateWorker.getVf(), selected, true)) { return myState.putAndPass(stateWorker.getVf(), TreeNodeState.HAVE_SELECTED_BELOW); } } return TreeNodeState.CLEAR; }