void () { TreePath[] treePaths = myTree.getSelectionPaths(); if (treePaths != null) { List<NamedConfigurable> selectedConfigurables = new ArrayList<>(); for (TreePath path : treePaths) { Object lastPathComponent = path.getLastPathComponent(); if (lastPathComponent instanceof MyNode) { selectedConfigurables.add(((MyNode)lastPathComponent).getConfigurable()); } } if (selectedConfigurables.size() > 1 && updateMultiSelection(selectedConfigurables)) { return; } } final TreePath path = myTree.getSelectionPath(); if (path != null) { final Object lastPathComp = path.getLastPathComponent(); if (!(lastPathComp instanceof MyNode node)) return; setSelectedNode(node); } else { setSelectedNode(null); } }