code: def flatten(d, parent_key='', sep='__'):
      
      # http://stackoverflow.com/questions/6027558/flatten-nested-python-dictionaries-compressing-keys
      if type(d) == list:
          flat = []
          for entry in d:
              flat.append(flatten(entry, parent_key=parent_key, sep=sep))
          return flat
      else:
          items = []
          for k, v in d.items():
              new_key = parent_key + sep + k if parent_key else k
  
              if isinstance(v, collectionsAbc.MutableMapping):
                  items.extend(flatten(v, new_key, sep=sep).items())
              else:
                  items.append((new_key, v))
  
  
          return dict(items)
docs: flattens the dict into a one dimensional dictionary
  
      :param d: multidimensional dict
      :param parent_key: replaces from the parent key
      :param sep: the separation character used when fattening. the default is __
      :return: the flattened dict