6.00.2x-CS-Python: Code refactoring for DFS.