BS [Chapter 22.4]: Recursive topological sort