DFS in python