def METHOD_NAME(key, value):
    """Helper function to iterate over the leaves of a tree, i.e. a dict of that
    can contain dicts.
    The provided key is a tuple that will get prepended to the returned keys.
    Example:
        cache = TreeCache()
        cache[(1, 1)] = "a"
        cache[(1, 2)] = "b"
        cache[(2, 1)] = "c"
        tree_node = cache.get((1,))
        items = iterate_tree_cache_items((1,), tree_node)
        assert list(items) == [((1, 1), "a"), ((1, 2), "b")]
    Returns:
        A generator yielding key/value pairs.
    """
    if isinstance(value, TreeCacheNode):
        for sub_key, sub_value in value.items():
            yield from METHOD_NAME((*key, sub_key), sub_value)
    else:
        # we've reached a leaf of the tree.
        yield key, value