private static void select(@NotNull MoveType type, @NotNull JTree tree, @Nullable TreePath path, int row) {
    if (path == null || row < 0) return;
    if (type == MoveType.ExtendSelection) {
      TreePath anchor = tree.getAnchorSelectionPath();
      int anchorRow = anchor == null ? -1 : tree.getRowForPath(anchor);
      if (anchorRow < 0) {
        tree.setSelectionPath(path);
      }
      else {
        tree.setSelectionInterval(row, anchorRow);
        tree.setAnchorSelectionPath(anchor);
        tree.setLeadSelectionPath(path);
      }
    }
    else if (type == MoveType.ChangeLead && DISCONTIGUOUS_TREE_SELECTION == tree.getSelectionModel().getSelectionMode()) {
      tree.setLeadSelectionPath(path);
    }
    else {
      tree.setSelectionPath(path);
    }
    TreeUtil.scrollToVisible(tree, path, false);
  }
private static void select(@NotNull MoveType type, @NotNull JTree tree, @Nullable TreePath path, int row)