Python (Simple DFS)
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```python3 []\nclass Solution:\n    def smallestMissingValueSubtree(self, parents, nums):\n        n, graph = len(parents), defaultdict(list)\n\n        for i in range(n):\n            if parents[i] != -1:\n                graph[parents[i]].append(i)\n\n        def function(node):\n            for neighbor in graph[node]:\n                if nums[neighbor] not in visited:\n                    visited.add(nums[neighbor])\n                    function(neighbor)\n\n        missing, visited, res, node = 1, set(), [1]*n, -1 \n\n        for i in range(n):\n            if nums[i] == 1:\n                node = i \n                break \n\n        if node == -1:\n            return res \n\n        while node != -1:\n            visited.add(nums[node])\n            function(node)\n            while missing in visited:\n                missing += 1 \n            res[node] = missing \n            node = parents[node]\n\n        return res \n```
['Python3']