Python Depth First Search Algorithm