def merge_map(old, new, deep_merge=False):
 if (not old):
  return new
 for (k, v) in new.items():
  if v:
   if (not deep_merge):
    old[k] = v
   elif isinstance(v, collections.Mapping):
    old_v = old.get(k)
    old[k] = (merge_map(old_v, v, deep_merge) if old_v else v)
   elif (isinstance(v, collections.Sequence) and (not isinstance(v, six.string_types))):
    old_v = old.get(k)
    old[k] = (merge_list(old_v, v) if old_v else v)
   elif isinstance(v, six.string_types):
    old[k] = ''.join([old.get(k, ''), v])
   else:
    old[k] = v
 return old

def merge_map ( old , new , deep_merge = False ) : if ( not old ) : return new for ( k , v ) in new . items ( ) : if v : if ( not deep_merge ) : old [ k ] = v elif isinstance ( v , collections . Mapping ) : old_v = old . get ( k ) old [ k ] = ( merge_map ( old_v , v , deep_merge ) if old_v else v ) elif ( isinstance ( v , collections . Sequence ) and ( not isinstance ( v , six . string_types ) ) ) : old_v = old . get ( k ) old [ k ] = ( merge_list ( old_v , v ) if old_v else v ) elif isinstance ( v , six . string_types ) : old [ k ] = '' . join ( [ old . get ( k , '' ) , v ] ) else : old [ k ] = v return old
merge nested dictionaries .