def flatten_dict(d, *, sep="."):
    """
    Flattens nested dicts into dotted names.
    """
    def _flatten(items):
        for k, v in items:
            if isinstance(v, dict):
                for kk, vv in _flatten(v.items()):
                    yield k + sep + kk, vv
            else:
                yield k, v

    return dict(_flatten(d.items()))