Exercise 2: Verifying a Full Subtree Recalculation — Possible Solution ==================================================================== SETUP ------------------------------ A real chain is created: "Programming" (top-level) -> "Web Development" (child of Programming) -> "React Fundamentals" (child of Web Development) - two real levels of descendants below "Web Development" itself once it's the page being moved (React Fundamentals is one level down, and a further page under React Fundamentals would be two). Moving "Web Development" under a different top-level page, e.g. "Archive", is the operation under test. TRACING movePage() ------------------------------ The moved page itself ("Web Development") gets its own new fullPath computed directly: archive/web-development. The recursive CTE then finds every descendant of the ORIGINAL "Web Development" row (before the move) - "React Fundamentals" at depth 1, and anything below it at depth 2 - ordered so depth 1 is processed before depth 2. The loop recalculates "React Fundamentals" using the already-updated recalculated map entry for its own parent (Web Development's new path), producing archive/web-development/react-fundamentals - then anything below THAT uses React Fundamentals's own freshly-recalculated path in turn. CONFIRMATION ------------------------------ Querying every page in the moved subtree afterward shows fullPath values that all correctly begin with the new archive/web-development/ prefix, at every depth - not just the directly-moved page, and not stopping after only the first level of children. WHY THIS WORKS AS AN ANSWER ------------------------------ It uses a real subtree at least two levels deep (not just one child, which wouldn't actually test whether deeper descendants inherit the correct parent path), and confirms every level was recalculated correctly using the previous level's own new path, not the old one - directly testing the recalculated Map's own role in the loop.