Well, recursion is best for trees. 🌳
It's great for traversing or constructing a TREE-LIKE STRUCTURE: a file system, arbitrarily nested dictionaries, JSON/YAML/TOML, an abstract syntax tree, etc.
This function walks a dict-of-dicts of unknown depth: https://pym.dev/p/249np/
Writing this WITHOUT recursion is possible, but painful.
If you're NOT working with a tree-like structure, there's probably a clean iterative solution hiding in your problem.
More: https://pym.dev/what-is-recursion/
🧵 (6/6)