def to_choices_dict(choices):
 ret = OrderedDict()
 for choice in choices:
  if (not isinstance(choice, (list, tuple))):
   ret[choice] = choice
  else:
   (key, value) = choice
   if isinstance(value, (list, tuple)):
    ret[key] = to_choices_dict(value)
   else:
    ret[key] = value
 return ret

def to_choices_dict ( choices ) : ret = OrderedDict ( ) for choice in choices : if ( not isinstance ( choice , ( list , tuple ) ) ) : ret [ choice ] = choice else : ( key , value ) = choice if isinstance ( value , ( list , tuple ) ) : ret [ key ] = to_choices_dict ( value ) else : ret [ key ] = value return ret
convert choices into key/value dicts .