def iterate_dict(d, parents=[]):
    """
    This function iterates over one dict and returns a list of tuples: (list_of_keys, value)
    Usefull for looping through a multidimensional dictionary.
    """

    r = []
    for k,v in d.iteritems():
        if isinstance(v, dict):
            r.extend(iterate_dict(v, parents + [k]))
        elif isinstance(v, list):
            r.append((parents + [k], v))
        else:
            r.append((parents + [k], v))
    return r