public static @Nullable TreePath getSelectedPathIfOne(@Nullable JTree tree) {
    TreePath[] paths = tree == null ? null : tree.getSelectionPaths();
    return paths != null && paths.length == 1 ? paths[0] : null;
  }
public static @Nullable TreePath getSelectedPathIfOne(@Nullable JTree tree)