void (@NotNull TreeNode node) { TreePath path = getPathFor(node); if (myTree.getSelectionModel().isPathSelected(path)) { TreePath parentPath = path.getParentPath(); myTree.getSelectionModel().removeSelectionPath(path); if (parentPath != null) { myTree.getSelectionModel().addSelectionPath(parentPath); } } }