def append_hook(target, key, value):
 if isinstance(value, dict):
  target.setdefault(key, {})
  for inkey in value:
   append_hook(target[key], inkey, value[inkey])
 else:
  target.setdefault(key, [])
  if (not isinstance(value, list)):
   value = [value]
  target[key].extend(value)

def append_hook ( target , key , value ) : if isinstance ( value , dict ) : target . setdefault ( key , { } ) for inkey in value : append_hook ( target [ key ] , inkey , value [ inkey ] ) else : target . setdefault ( key , [ ] ) if ( not isinstance ( value , list ) ) : value = [ value ] target [ key ] . extend ( value )
appends a hook to the the target dict .