There is a flatten method in src/metaswitch/crest/api/utils.py