Coerce a dictionary to a bottle.MultiDict

def as_multi_dict(d):
    'Coerce a dictionary to a bottle.MultiDict'
    if isinstance(d, bottle.MultiDict):
        return d
    md = bottle.MultiDict()
    for k, v in d.iteritems():
        if isinstance(v, list):
            for x in v:
                md[k] = x
        else:
            md[k] = v
    return md