code: def split_key(d, key, new_keys, before=True,
                list_of_dicts=False, deepcopy=True):
      
      list_of_dicts = '__list__' if list_of_dicts else None
      flatd = flatten(d, list_of_dicts=list_of_dicts)
  
      newd = {}
      for path, v in flatd.items():
          if key in path:
              newk = []
              for k in path:
                  if k == key:
                      if before:
                          newk = newk + new_keys + [k]
                      else:
                          newk = newk + [k] + new_keys
                  else:
                      newk.append(k)
              newd[tuple(newk)] = v
          else:
              newd[path] = v
  
      return unflatten(newd, list_of_dicts=list_of_dicts, deepcopy=deepcopy)
docs: split an existing key(s) into multiple levels
  
      Parameters
      ----------
      d : dict
          or dict like
      key: str
          existing key value
      new_keys: list[str]
          new levels to add
      before: bool
          add level before existing key (else after)
      list_of_dicts: bool
          treat list of dicts as additional branches
  
      Examples
      --------
      >>> from pprint import pprint
      >>> d = {'a':1,'b':2}
      >>> pprint(split_key(d,'a',['c','d']))
      {'b': 2, 'c': {'d': {'a': 1}}}
  
      >>> pprint(split_key(d,'a',['c','d'],before=False))
      {'a': {'c': {'d': 1}}, 'b': 2}
  
      >>> d2 = [{'a':1},{'a':2},{'a':3}]
      >>> pprint(split_key(d2,'a',['b'],list_of_dicts=True))
      [{'b': {'a': 1}}, {'b': {'a': 2}}, {'b': {'a': 3}}]