Maze solver implementation in Python