tree.md One-line Tree in Python Using Python's built-in defaultdict we can easily define a tree data structure: def tree(): return defaultdict(tree) That's it! It simply says that a tree is a dict whose default values are trees. (If you're following along at home, make sure to from collections import defaultdict) (Also: Hacker News reader @zbuc points out that this is called autovivification. Cool