@Nullable
  private static ChangesBrowserNode<?> collapseParentWithOnlyChild(@NotNull ChangesBrowserNode<?> parent,
                                                                   @NotNull ChangesBrowserNode<?> child) {
    if (child.isLeaf()) return null;

    Object parentUserObject = parent.getUserObject();
    Object childUserObject = child.getUserObject();

    if (parentUserObject instanceof FilePath &&
        childUserObject instanceof FilePath) {
      return child;
    }

    if (parent instanceof ChangesBrowserNode.NodeWithFilePath parentWithPath &&
        childUserObject instanceof FilePath childPath) {
      FilePath parentPath = parentWithPath.getNodeFilePath();
      if (!parentPath.equals(childPath)) return null;

      parent.remove(0);

      List<ChangesBrowserNode<?>> children = child.iterateNodeChildren().toList(); // defensive copy
      for (ChangesBrowserNode<?> childNode : children) {
        parent.add(childNode);
      }

      return parent;
    }

    return null;
  }
@Nullable
  private static ChangesBrowserNode<?> collapseParentWithOnlyChild(@NotNull ChangesBrowserNode<?> parent,
                                                                   @NotNull ChangesBrowserNode<?> child)