human
I wrote the below code

    if (len(actualEvents) != len(expectedEvents)):
        test.assertEqual(actualEvents, expectedEvents)
    allMergedKeys = set()
    for event in expectedEvents:
        allMergedKeys |= set(event.keys())
    def simplify(event):
        copy = event.copy()
        for key in event.keys():
            if (key not in allMergedKeys):
                copy.pop(key)
        return copy
    simplifiedActual = [simplify(event) for event in actualEvents]
    test.assertEqual(simplifiedActual, expectedEvents)

What's a good function header?
 Here's a good function header?
assistant
#Here's a good function header.

def compareEvents(test, actualEvents, expectedEvents):