class DFSStrategy:
    def find_path(self, maze, start, exit_):
        stack = [start]
        parent = {start: None}
        visited = {start}

        while stack:
            cur = stack.pop()

            if cur == exit_:
                return self._reconstruct(parent, start, exit_), visited

            for n in maze.get_neighbors(cur):
                if n not in visited:
                    visited.add(n)
                    parent[n] = cur
                    stack.append(n)

        return None, visited

    def _reconstruct(self, parent, start, exit_):
        path = []
        cur = exit_
        while cur:
            path.append(cur)
            cur = parent[cur]
        return list(reversed(path))
