code: def merge(a, b, path=None):
      
      if path is None:
          path = []
      for key in b:
          if key in a:
              if isinstance(a[key], dict) and isinstance(b[key], dict):
                  merge(a[key], b[key], path + [str(key)])
              elif a[key] == b[key]:
                  pass  # same leaf value
              else:
                  a[key] = b[key]
                  # raise Exception("Conflict at %s (%s %s)" % (".".join(path + [str(key)]),
                  #                 a[key], b[key]))
          else:
              a[key] = b[key]
      return a
docs: merges b into a
  
      >>> a={1:{"a":"A"},2:{"b":"B"}, 8:[]}
      >>> b={2:{"c":"C"},3:{"d":"D"}}
  
      >>> c = merge(a, b)
      >>> c == a == {8: [], 1: {"a": "A"}, 2: {"c": "C", "b": "B"}, 3: {"d": "D"}}
      True
  
      >>> c = merge(a, {1: "a"})
      >>> print(c[1])
      a