code: def deep_update(dict1, dict2):
      
      def flatten(v):
          if isinstance(v, ModifyList):
              return v.apply([])
          elif isinstance(v, dict):
              return dict((k, flatten(v_)) for k, v_ in v.iteritems())
          else:
              return v
  
      def merge(v1, v2):
          if isinstance(v1, dict) and isinstance(v2, dict):
              deep_update(v1, v2)
              return v1
          elif isinstance(v2, ModifyList):
              v1 = flatten(v1)
              return v2.apply(v1)
          else:
              return flatten(v2)
  
      for k1, v1 in dict1.iteritems():
          if k1 not in dict2:
              dict1[k1] = flatten(v1)
  
      for k2, v2 in dict2.iteritems():
          v1 = dict1.get(k2)
  
          if v1 is KeyError:
              dict1[k2] = flatten(v2)
          else:
              dict1[k2] = merge(v1, v2)
docs: Perform a deep merge of `dict2` into `dict1`.
  
      Note that `dict2` and any nested dicts are unchanged.
  
      Supports `ModifyList` instances.