if (treeModel.getIndexOfChild(root, node) != -1)
int size = treeModel.getChildCount(root); for (int j = 0; j < size; j++) { Object child = treeModel.getChild(root, j); if (node.equals(child))
  private Object findNode(Object root, Object node)  {    int size = 0;    if (!treeModel.isLeaf(root))      size = treeModel.getChildCount(root);    for (int i = 0; i < size; i++)      {        if (treeModel.getIndexOfChild(root, node) != -1)          return root;        Object n = findNode(treeModel.getChild(root, i), node);        if (n != null)          return n;      }    return null;  }