code: private static DefaultMutableTreeNode findNode(
          TreeModel treeModel, Object node, Object userObject)
      {
          if (node instanceof DefaultMutableTreeNode)
          {
              DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)node;
              Object object = treeNode.getUserObject();
              if ((object == null && userObject == null) ||
                  (object != null && object.equals(userObject)))
              {
                  return treeNode;
              }
          }
          int n = treeModel.getChildCount(node);
          for (int i=0; i<n; i++)
          {
              Object child = treeModel.getChild(node, i);
              DefaultMutableTreeNode result = 
                  findNode(treeModel, child, userObject);
              if (result != null)
              {
                  return result;
              }
          }
          return null;
      }
docs: Returns the node with the given user object in the tree that is
  rooted at the given node in the given model. This assumes that
  the user object is stored in a DefaultMutableTreeNode.
  Returns <code>null</code> if no matching node is found.
  
  @param treeModel The tree model
  @param node The root node
  @param userObject The user object
  @return The node with the given user object, or <code>null</code>