'Ensure that we don\'t have the same event twice.
Pick the earliest non-outlier if there is one, else the earliest one.
Args:
events_and_contexts (list[(EventBase, EventContext)]):
Returns:
list[(EventBase, EventContext)]: filtered list'

@classmethod
def _filter_events_and_contexts_for_duplicates(cls, events_and_contexts):

    new_events_and_contexts = OrderedDict()
    for (event, context) in events_and_contexts:
        prev_event_context = new_events_and_contexts.get(event.event_id)
        if prev_event_context:
            if (not event.internal_metadata.is_outlier()):
                if prev_event_context[0].internal_metadata.is_outlier():
                    new_events_and_contexts.pop(event.event_id, None)
                    new_events_and_contexts[event.event_id] = (event, context)
        else:
            new_events_and_contexts[event.event_id] = (event, context)
    return new_events_and_contexts.values()
