def convert_dicts(d, to_class=AttrDictWrapper, from_class=dict):
d_ = to_class()<EOL>for key, value in d.iteritems():<EOL><INDENT>if isinstance(value, from_class):<EOL><INDENT>d_[key] = convert_dicts(value, to_class=to_class,<EOL>from_class=from_class)<EOL><DEDENT>else:<EOL><INDENT>d_[key] = value<EOL><DEDENT><DEDENT>return d_<EOL>
Recursively convert dict and UserDict types.

    Note that `d` is unchanged.

    Args:
        to_class (type): Dict-like type to convert values to, usually UserDict
            subclass, or dict.
        from_class (type): Dict-like type to convert values from. If a tuple,
            multiple types are converted.

    Returns:
        Converted data as `to_class` instance.