TreePath (final DefaultMutableTreeNode node) { final TreeNode[] path = node.getPath(); final TreePath treePath = new TreePath(path); TreePath expandPath = treePath; if (myTree.getModel().isLeaf(expandPath.getLastPathComponent())) { expandPath = expandPath.getParentPath(); } myTree.expandPath(expandPath); return treePath; }