def DictToAdditionalPropertyMessage(properties, additional_property_type,
                                    sort_items=False):
    """Convert the given dictionary to an AdditionalProperty message."""
    items = properties.items()
    if sort_items:
        items = sorted(items)
    map_ = []
    for key, value in items:
        map_.append(additional_property_type.AdditionalProperty(
            key=key, value=value))
    return additional_property_type(additionalProperties=map_)
Convert the given dictionary to an AdditionalProperty message.