def default_to_regular(d):
    if isinstance(d, defaultdict):
        d = {k: default_to_regular(v) for k, v in d.items()}
How to convert defaultdict of defaultdicts [of defaultdicts] to dict of dicts [of dicts]?