Dfs Algorithm In Python Using Global Variables