breadth first search for maze