Swapped from using a stack to using a queue for DFS.