[Python] Climb up
\nOnly node 1 and its ancestor have res[i] > 1.\nOnly LCA(1,2) and its ancestor have res[i] > 2. (LCA = lowest common ancestor)\nOnly LCA(1,2,3) and its ancesto
\nOnly node 1 and its ancestor have `res[i]` > 1.\nOnly LCA(1,2) and its ancestor have `res[i]` > 2. (LCA = lowest common ancestor)\nOnly LCA(1,2,3) and its ancestor have `res[i] > 3`\nEtc...\nStarting from node 1, process each`x`  in range 2..n , move the current node and `node x` both one level up until they reach their common ancestor to find their LCA (using level lifting technique). Each time the curent node move up, update its parent\'s value to be the same as its current value.\n\n```python\ndef smallestMissingValueSubtree(self, parents: List[int], nums: List[int]) -> List[int]:\n        n = len(parents)\n        res = [1] * n \n        level = [0] * n \n        parents[0] = 0 \n        def f(i):\n            if i and level[i] == 0:\n                level[i] = f(parents[i])+1\n            return level[i]\n        \n        def climb(u):\n            if u == c[0]:\n                return u\n            temp = c[0]\n            if f(c[0]) > f(u):\n                res[parents[c[0]]] = res[c[0]]\n                c[0] = parents[c[0]]\n                p = parents[temp] = climb(u)\n            else:\n                parents[u] = p = climb(parents[u])\n            return p \n            \n            \n        a = {j:i for i,j in enumerate(nums) }\n        c = [a.get(1,0)]\n        for i in range(1, n+1):\n            u = a.get(i)\n            if u == None:\n                break\n            climb(u)\n            res[c[0]] += 1\n        climb(0)\n        return res\n```
[]