def _build_alerts(data):
    """
    Helper function that extracts all the alerts from data and returns them as a list
    """
    alerts = []
    for item in data:
        events = item['return']
        if not isinstance(events, list):
            events = [events]
        alerts.extend(events)

    return alerts