def recursive_keypairs(d, separator=':'):
 for (name, value) in sorted(six.iteritems(d)):
  if isinstance(value, dict):
   for (subname, subvalue) in recursive_keypairs(value, separator):
    (yield (('%s%s%s' % (name, separator, subname)), subvalue))
  elif isinstance(value, (tuple, list)):
   (yield (name, decode_unicode(value)))
  else:
   (yield (name, value))

def recursive_keypairs ( d , separator = ':' ) : for ( name , value ) in sorted ( six . iteritems ( d ) ) : if isinstance ( value , dict ) : for ( subname , subvalue ) in recursive_keypairs ( value , separator ) : ( yield ( ( '%s%s%s' % ( name , separator , subname ) ) , subvalue ) ) elif isinstance ( value , ( tuple , list ) ) : ( yield ( name , decode_unicode ( value ) ) ) else : ( yield ( name , value ) )
generator that produces sequence of keypairs for nested dictionaries .