You practiced building the table from a parent array. You implemented the binary decomposition loop to answer queries. You also handled edge cases: queries where exceeds depth.
This problem is the template for all binary lifting problems. If you can solve this, you can solve any -th ancestor problem. The same table structure is reused for LCA queries, path aggregation, and other tree problems that need fast ancestor lookups.