private static boolean shouldAutoExpand(JTree tree, TreePath path) {
    return tree != null && isAutoExpandAllowed(tree) && tree.isVisible(path);
  }
private static boolean shouldAutoExpand(JTree tree, TreePath path)