boolean (TreeSelection treeSelection) { if (treeSelection.isEmpty()) return false; DefaultMutableTreeNode root = (DefaultMutableTreeNode)myTreeModel.getRoot(); for (int i = 0; i < root.getChildCount(); i++) { TreeNode node = root.getChildAt(i); if (node instanceof MessageNode messageNode) { String[] text = messageNode.getText(); if (text.length == 0) continue; if (Objects.equals(treeSelection.mySelectedTarget, text[0])) { TreePath pathToSelect = new TreePath(messageNode.getPath()); for (Enumeration enumeration = messageNode.children(); enumeration.hasMoreElements();) { Object o = enumeration.nextElement(); if (o instanceof MessageNode) { messageNode = (MessageNode)o; if (Objects.equals(treeSelection.mySelectedTask, text[0])) { pathToSelect = new TreePath(messageNode.getPath()); break; } } } TreeUtil.selectPath(myTree, pathToSelect); myTree.expandPath(pathToSelect); return true; } } } return false; }