One thing to keep in mind (which the original cited article in this article gets right, but this article gets wrong) - there is no guarnateed unique ordering of children visitation for nodes with >1 child. The parts they copy from the original article talk about this correctly, the parts they didn't, don't :)

The DFS orderings where the children visitation is swapped, etc, are all still equally correct and valid. That is - a DFS algorithm that randomized the children order is still valid.

IE for example, if you change the "for nbr in graph[node]" line to "for nbr in reversed(sorted(graph[node]))", the resulting DFS ordering is still valid and correct.

If you want them in a specific ordering, you'd usually have to force them into it in the algorithm. It rarely makes sense to try to force the structure to be ordered (as they do here) for the algorithm.

This often hits people who use graphs with pointers, or multiple threads, or ...