from task2.mazeObjects.maze import Maze
from task2.mazeObjects.cell import Cell

def restorePath(parents: dict, exit: Cell) -> list[Cell]|None:
    path = []
    current = exit
    while current:
        path.append(current)
        if current not in parents:
            return None
        current = parents[current]
    return path[::-1]