if (next == null) return;
  void updateCurrentVisiblePath()  {    if (treeModel == null)      return;    Object next = treeModel.getRoot();    TreePath rootPath = new TreePath(next);    Rectangle bounds = getPathBounds(tree, rootPath);        // If root is not a valid size to be visible, or is    // not visible and the tree is expanded, then the next node acts    // as the root    if ((bounds.width == 0 && bounds.height == 0) || (!isRootVisible()        && tree.isExpanded(new TreePath(next))))      {      next = getNextNode(next);        rootPath = new TreePath(next);      }    Object root = next;    TreePath current = null;    while (next != null)      {        if (current == null)          current = rootPath;        else             current = current.pathByAddingChild(next);                do          {            TreePath path = new TreePath(getPathToRoot(next, 0));            if ((tree.isVisible(path) && tree.isExpanded(path))                || treeModel.isLeaf(next))          next = getNextNode(next);            else              {                Object pNext = next;                next = getNextSibling(pNext);                // if no next sibling, check parent's next sibling.                if (next == null)                  {                    Object parent = getParent(root, pNext);                    while (next == null && parent != null)                      {                        next = getNextSibling(parent);                        if (next == null)                          parent = getParent(root, parent);                      }          }      }          }        while (next != null &&             !tree.isVisible(new TreePath(getPathToRoot(next, 0))));      }    currentVisiblePath = current;    tree.setVisibleRowCount(getRowCount(tree));        if (tree.getSelectionModel() != null && tree.getSelectionCount() == 0 &&        currentVisiblePath != null)      selectPath(tree, new TreePath(getPathToRoot(currentVisiblePath.                                                  getPathComponent(0), 0)));  }