Mark-and-sweep is the algorithm McCarthy invented for Lisp in 1960 and it still runs today: CPython's cycle collector, Lua's GC, and the foundation of every JVM collector trace from roots exactly as you implement here. Writing one makes the terms in every GC tuning guide — roots, reachability, stop-the-world — concrete.