There are many Python questions on how to do an infinitely-nested/recursive defaultdict, which one(s) should be canonical?
- Nested insertion/creation of dictionary
- Multi-level defaultdict with variable depth?
- Is there a standard class for an infinitely nested defaultdict? [No, but it's typically a one-liner]
- Recommended Nested defaultdict of defaultdict
- ...please add to this list...
Known duplicates:
Related but distinct:
- Can't pickle recursive nested defaultdict
- PERL-like autovivification with default value in Python, and returns a default value from non-existing arbitrary nesting?
- Set Python dict items recursively, when given a compound key 'foo.bar.baz'
- How to convert dict into recursive defaultdict and load JSON?
and even:
setdefault