def merge_dict(d1, d2):
    """
    Modifies d1 in-place to contain values from d2.  If any value
    in d1 is a dictionary (or dict-like), *and* the corresponding
    value in d2 is also a dictionary, then merge them in-place.
    """
for k, v2 in list(d2.items()):
    v1 = d1.get(k)
if isinstance(v1, collections.Mapping) and isinstance(v2, collections.Mapping):
    pass
Python, объединить многоуровневые словари