<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def deep_update(dict1, dict2):
 """Perform a deep merge of `dict2` into `dict1`. Note that `dict2` and any nested dicts are unchanged. Supports `ModifyList` instances. """

    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)