Python (Simple DFS + Union Find)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def smallestMissingValueSubtree(self, parents, nums):\n        dict1 = defaultdict(int)\n\n        def find(x):\n            if x not in dict1:\n                return x\n            else:\n                if x != dict1[x]:\n                    dict1[x] = find(dict1[x])\n                return dict1[x]\n\n        def union(x,y):\n            a,b = find(x),find(y)\n\n            if a == b: return 0\n\n            dict1[b] = a\n\n            return a\n\n\n        def dfs(tree):\n            smallest = max({dfs(subtree) for subtree in graph[tree]}|{1})\n\n            for subtree in graph[tree]:\n                union(nums[tree],nums[subtree])\n\n            for i in range(smallest,n+1):\n                if find(i) != find(nums[tree]):\n                    res[tree] = i\n                    return i\n            \n            return i+1\n\n\n        n, graph = len(nums), defaultdict(list)\n        res = [1]*n\n\n        for i,p in enumerate(parents):\n            graph[p].append(i)\n\n        res[0] = dfs(0)\n\n        return res\n\n        \n\n\n\n\n\n\n\n\n            \n\n\n\n\n            \n\n\n\n\n        \n\n\n\n        \n        \n```
['Python3']