Pattern matching on Python object structures