depth first search explained and python code line by line explanation