def get_events(trace_collection, keys=None, syscall=True):
    """Return a generator of events. An event is a dict with the key the
    arguement's name.

    Args:
        trace_collection (babeltrace.TraceCollection): Trace from which
            to read the events.
        keys (dict, optional): dict of the multiple ways of the arguments
            to consider in addition to name and timestamp.
        syscall (bool, optional): only syscall should be considered

    Returns:
        generator: a generator of events.
    """
    return (
        {
            **{
                'name': event.name,
                'timestamp': event.timestamp
            },
            **{
                keys[k]: event[k]
                # scope 3 = Stream event context (procname, pid, tid)
                for k in event.field_list_with_scope(3) if keys and k in keys
            },
            **{
                keys[k]: event[k]
                # scope 5 = Event fields (return value)
                for k in event.field_list_with_scope(5) if keys and k in keys
            }
        } for event in trace_collection.events
        if not syscall or "syscall" in event.name)