code: def data_merge(a, b):
      
      key = None
      # ## debug output
      # sys.stderr.write("DEBUG: %s to %s\n" %(b,a))
      try:
          if a is None or isinstance(a, (six.string_types, float, six.integer_types)):
              # border case for first run or if a is a primitive
              a = b
          elif isinstance(a, list):
              # lists can be only appended
              if isinstance(b, list):
                  # merge lists
                  a.extend(b)
              else:
                  # append to list
                  a.append(b)
          elif isinstance(a, dict):
              # dicts must be merged
              if isinstance(b, dict):
                  for key in b:
                      if key in a:
                          a[key] = data_merge(a[key], b[key])
                      else:
                          a[key] = b[key]
              else:
                  raise YamlReaderError('Cannot merge non-dict "%s" into dict "%s"' % (b, a))
          else:
              raise YamlReaderError('NOT IMPLEMENTED "%s" into "%s"' % (b, a))
      except TypeError as e:
          raise YamlReaderError('TypeError "%s" in key "%s" when merging "%s" into "%s"' % (e, key, b, a))
      return a
docs: merges b into a and return merged result
      based on http://stackoverflow.com/questions/7204805/python-dictionaries-of-dictionaries-merge
      and extended to also merge arrays and to replace the content of keys with the same name
  
      NOTE: tuples and arbitrary objects are not handled as it is totally ambiguous what should happen