depth first search for the maze