public static void removeLastPathComponent(final @NotNull JTree tree, final @NotNull TreePath pathToBeRemoved){
    removeLastPathComponent((DefaultTreeModel)tree.getModel(), pathToBeRemoved).restoreSelection(tree);
  }
public static void removeLastPathComponent(final @NotNull JTree tree, final @NotNull TreePath pathToBeRemoved)