def first_non_empty(data_or_instance, field_or_fields, default=None):
    """
    Return the first non-empty attribute of `instance` or `default`

    :type data_or_instance: object or dict
    :param data_or_instance: the instance or the resource
    :type field_or_fields: str or tuple or list
    :param field_or_fields: the field or fields to look for on the resource
    :type default: anything
    :param default: the default value to return if no non-empty field was found, default to None
    :return: the first non-empty field of `instance` or `default`
    """

    # Convert `data_or_instance` to an object-like structure
    # so attributes can be fetched with `getattr` regardless of the initial type.
    if isinstance(data_or_instance, dict):
        class ObjectView(object):
            def __init__(self, d):
                self.__dict__ = d

        obj = ObjectView(data_or_instance)

    else:
        obj = data_or_instance

    # Find the first non-empty.
    if isinstance(field_or_fields, str):
        return getattr(obj, field_or_fields, default)

    elif isinstance(field_or_fields, (tuple, list)):
        for field in field_or_fields:
            val = getattr(obj, field, None)
            if val:
                return val

    return default