def unpack_unique_together(opts, only_fields=()):
    """
    Unpack unique together fields.

    :param opts: Model options
    :type opts: `django.db.models.options.Options`
    :param only_fields: Fields that should be considered.
    :type only_fields: `collections.Iterable`
    :return: Flat list of fields.
    """
    fields = []
    for field in opts.unique_together:
        fields.extend(list([f for f in field if f in only_fields]))
    return fields