def merge_versioned(releases, schema=None, merge_rules=None):
    """
    Merges a list of releases into a versionedRelease.
    """
    if not merge_rules:
        merge_rules = get_merge_rules(schema)

    merged = OrderedDict()
    for release in sorted(releases, key=lambda release: release['date']):
        release = release.copy()

        # Don't version the OCID.
        ocid = release.pop('ocid')
        merged[('ocid',)] = ocid

        releaseID = release['id']
        date = release['date']
        # Prior to OCDS 1.1.4, `tag` didn't set "omitWhenMerged": true.
        tag = release.pop('tag', None)

        flat = flatten(release, merge_rules)
        processed = process_flattened(flat)

        for key, value in processed.items():
            # If value is unchanged, don't add to history.
            if key in merged and value == merged[key][-1]['value']:
                continue

            if key not in merged:
                merged[key] = []

            merged[key].append(OrderedDict([
                ('releaseID', releaseID),
                ('releaseDate', date),
                ('releaseTag', tag),
                ('value', value),
            ]))

    return unflatten(merged, merge_rules)