The below code example uses a recursive definition. To my understanding, whenever a key is defined, its corresponding value is set as a dictionary as default. This way of definition allows arbitrary depth.
import collections
tree = lambda: collections.defaultdict(tree)
some_dict = tree()
some_dict['color']['favor'] = "yellow"
However, I do not understand why not defining as the following way:
import collections
tree = collections.defaultdict(collections.defaultdict)
It seems both way work correctly. They both allow defining dictionary of arbitrary depth. Are they different in any sense?