boolean (final Object[] oldSelectionPath, final int idx, final TreeNode node) { if (idx >= oldSelectionPath.length) { return false; } if ((oldSelectionPath[idx] != null) && (oldSelectionPath[idx].toString() != null)) { final Enumeration children = node.children(); while (children.hasMoreElements()) { final TreeNode child = (TreeNode) children.nextElement(); if (oldSelectionPath[idx].toString().equals(child.toString())) { final boolean childStatus = setSelection(oldSelectionPath, idx + 1, child); if (! childStatus) { myTree.setSelectionPath(new TreePath(((DefaultTreeModel) myTree.getModel()).getPathToRoot(child))); } return true; } } } myTree.setSelectionPath(new TreePath(((DefaultTreeModel) myTree.getModel()).getPathToRoot(node))); return true; }