code: def extract(d, path=None):
      
      path = [] if path is None else path
  
      d_new = copy.deepcopy(d)
      d_sub = d_new
      for key in path[:-1]:
          d_sub = d_sub[key]
  
      key = path[-1]
      d_extract = {key: d_sub[key]}
      d_sub.pop(key)
  
      return d_new, d_extract
docs: extract section of dictionary
  
      Parameters
      ----------
      d : dict
      path : list[str]
          keys to section
  
      Returns
      -------
      new_dict : dict
          original, without extracted section
      extract_dict : dict
          extracted section
  
      Examples
      --------
  
      >>> from pprint import pprint
      >>> d = {1:{"a":"A"},2:{"b":"B",'c':'C'}}
      >>> pprint(extract(d,[2,'b']))
      ({1: {'a': 'A'}, 2: {'c': 'C'}}, {'b': 'B'})