TreeNodeState (final T node, final @NotNull TreeNodeState state) { if (TreeNodeState.SELECTED.equals(state)) { mySelected.add(node); myCache.remove(node); } else { mySelected.remove(node); myCache.put(node, state); } return state; }