int row = Math.round(y / getMaxHeight(tree)); TreePath path = getPathForRow(tree, row);   while (row > 0 && path == null) { --row; path = getPathForRow(tree, row); }  return path;
return treeState.getPathClosestTo(x, y);
  public TreePath getClosestPathForLocation(JTree tree, int x, int y)  {    int row = Math.round(y / getMaxHeight(tree));    TreePath path = getPathForRow(tree, row);    // no row is visible at this node    while (row > 0 && path == null)      {        --row;        path = getPathForRow(tree, row);      }    return path;  }