def getattr_(entity, attribute):
    """Either unpack the attribute from every item in the entity
    if the entity is a list, otherwise just return the attribute
    from the entity. Returns None if the entity is either None
    or empty."""
    if entity in (None, []):
        return None
    if isinstance(entity, list):
        return [getattr(item, attribute) for item in entity]
    return getattr(entity, attribute)