def flatten_dict(product_model_dict):
    """ Converts a dict with nested attributes into a flattened dict,
        where the path to each attribute in the original dict maps to
        a key in the new dict.

            > d = {'a': 1, 'b': {'c': 2, 'd': {'e': 3, 'f': 4}}}
            > ProductModel._flatten_dict(d)
            {'a': 1, 'b.c': 2, 'b.d.e': 3, 'b.d.f': 4}

        :param product_model_dict: the original dict.
        :returns: a flattened dict.
    """
    result = {}
    for key, value in product_model_dict.items():
        if isinstance(value, dict):
            subdict = flatten_dict(value)
            for sk, sv in subdict.items():
                result[key + '.' + sk] = sv
        else:
            result[key] = value
    return result