It's better to use BFS instead DFS for this task (optional fix)