class MyDict(dict):
    def __init__(self):
        pass
    
    @staticmethod
    def flatten(d, parent_key='', sep='_'):
        """ flattens dict. items recursively"""
        items = []
        for k, v in d.items():
            new_key = parent_key + sep + k if parent_key else k
            if isinstance(v, MutableMapping):
                items.extend(MyDict.flatten(v, new_key, sep=sep).items())
            else:
                items.append((new_key, v))
        return dict(items)
      
