boolean (TreePath path, DefaultMutableTreeNode child) { for (Object o : path.getPath()) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)o; if (node != child && Comparing.equal(node.getUserObject(), child.getUserObject())) { return true; } } return false; }