for (int i = 0; i < mod.getChildCount(root); i++)
int size = 0; if (!mod.isLeaf(root)) size = mod.getChildCount(root); for (int i = 0; i < size; i++)
  private Object findNode(Object root, Object node)  {    TreeModel mod = tree.getModel();    for (int i = 0; i < mod.getChildCount(root); i++)      {        if (mod.getIndexOfChild(root, node) != -1)          return root;        Object n = findNode(mod.getChild(root, i), node);        if (n != null)          return n;      }    return null;  }