def METHOD_NAME(versions):
    """Add a diff to each of an array of version dicts
    The first version is the most recent; the last is the original
    version."""
    if not versions:
        return []
    id_to_parent_ids = get_versions_parent_map(versions)
    id_to_version = {v["version_id"]: v for v in versions}
    result = []
    for v in versions:
        version_id = v["version_id"]
        v["parent_version_ids"] = id_to_parent_ids[version_id]
        version_with_diffs = v.copy()
        version_with_diffs["data"] = clean_version_data(
            version_with_diffs["data"]
        )
        version_with_diffs["parent_version_ids"] = id_to_parent_ids[version_id]
        version_with_diffs["diffs"] = [
            {
                "parent_version_id": parent_with_data[0],
                "parent_diff": get_version_diff(
                    clean_version_data(parent_with_data[1]),
                    version_with_diffs["data"],
                ),
            }
            for parent_with_data in get_parents_version_data(
                id_to_parent_ids[version_id], id_to_version
            )
        ]
        result.append(version_with_diffs)
    return result