TreePath (MavenArchetype object, TreeModel model, Object parent) { for (int i = 0; i < model.getChildCount(parent); i++) { DefaultMutableTreeNode each = (DefaultMutableTreeNode)model.getChild(parent, i); if (each.getUserObject().equals(object)) return new TreePath(each.getPath()); TreePath result = findNodePath(object, model, each); if (result != null) return result; } return null; }