code: def list_to_dict(lst, key=None, remove_key=True):
      
  
      assert all([is_dict_like(d) for d in lst])
      if key is not None:
          assert all([key in d for d in lst])
      new_dict = {}
      for i, d in enumerate(lst):
          d = unflatten(flatten(d))
          if key is None:
              new_dict[str(i)] = d
          else:
              if remove_key:
                  k = d.pop(key)
              else:
                  k = d[key]
              new_dict[k] = d
  
      return new_dict
docs: convert a list of dicts to a dict with root keys
  
      Parameters
      ----------
      lst : list[dict]
      key : str or None
          a key contained by all of the dicts
          if None use index number string
      remove_key : bool
          remove key from dicts in list
  
      Examples
      --------
      >>> from pprint import pprint
      >>> lst = [{'name':'f','b':1},{'name':'g','c':2}]
      >>> pprint(list_to_dict(lst))
      {'0': {'b': 1, 'name': 'f'}, '1': {'c': 2, 'name': 'g'}}
  
      >>> pprint(list_to_dict(lst,'name'))
      {'f': {'b': 1}, 'g': {'c': 2}}