void (JTree tree, TreePath path) { final TreeNode node = ((TreeNode)path.getLastPathComponent()); final Enumeration children = node.children(); while (children.hasMoreElements()) { TreeNode child = (TreeNode)children.nextElement(); collapsePath(tree, path.pathByAddingChild(child)); } if (!((path.getLastPathComponent() == tree.getModel().getRoot()) && !myRootVisible)) { tree.collapsePath(path); } }