def mergedicts(d1, d2, remove=True):
 _setmerged(d1, d2)
 for k in d2:
  if ((k in d1) and isinstance(d1[k], dict) and isinstance(d2[k], dict)):
   mergedicts(d1[k], d2[k], remove)
  elif (remove and (d2[k] is REMOVE_THIS_KEY)):
   d1.pop(k, None)
  else:
   if (remove and isinstance(d2[k], dict)):
    _clear_special_values(d2[k])
   d1[k] = d2[k]

def mergedicts ( d1 , d2 , remove = True ) : _setmerged ( d1 , d2 ) for k in d2 : if ( ( k in d1 ) and isinstance ( d1 [ k ] , dict ) and isinstance ( d2 [ k ] , dict ) ) : mergedicts ( d1 [ k ] , d2 [ k ] , remove ) elif ( remove and ( d2 [ k ] is REMOVE_THIS_KEY ) ) : d1 . pop ( k , None ) else : if ( remove and isinstance ( d2 [ k ] , dict ) ) : _clear_special_values ( d2 [ k ] ) d1 [ k ] = d2 [ k ]
recursively merge two dictionaries first dictionary is modified in-place .