def semiflatten(multi):
if multi:<EOL><INDENT>result = multi.to_dict(flat=False)<EOL>for k, v in result.items():<EOL><INDENT>if len(v) == <NUM_LIT:1>:<EOL><INDENT>result[k] = v[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>return result<EOL><DEDENT>else:<EOL><INDENT>return multi<EOL><DEDENT>
Convert a MutiDict into a regular dict. If there are more than one value
    for a key, the result will have a list of values for the key. Otherwise it
    will have the plain value.