def update_nested(original_dict, updates):
 dict_to_update = copy.deepcopy(original_dict)
 for (key, value) in six.iteritems(updates):
  if isinstance(value, dict):
   sub_dict = update_nested(dict_to_update.get(key, {}), value)
   dict_to_update[key] = sub_dict
  else:
   dict_to_update[key] = updates[key]
 return dict_to_update

def update_nested ( original_dict , updates ) : dict_to_update = copy . deepcopy ( original_dict ) for ( key , value ) in six . iteritems ( updates ) : if isinstance ( value , dict ) : sub_dict = update_nested ( dict_to_update . get ( key , { } ) , value ) dict_to_update [ key ] = sub_dict else : dict_to_update [ key ] = updates [ key ] return dict_to_update
updates the leaf nodes in a nest dict .