My AC C++ Solution using DFS
\nclass Solution {\nprivate:\n    unordered_set <int> Set;\n    vector <int> Values;\n    vector <vector <int>> Graph;\n    void DFS(int idx, vector <int> &nums
```\nclass Solution {\nprivate:\n    unordered_set <int> Set;\n    vector <int> Values;\n    vector <vector <int>> Graph;\n    void DFS(int idx, vector <int> &nums) {\n        for (int &children: Graph[idx]) {\n            if (Set.find(nums[children]) != Set.end()) continue;\n            Set.insert(nums[children]);\n            DFS(children, nums);\n        }\n    }\npublic:\n    vector<int> smallestMissingValueSubtree(vector<int>& parents, vector<int>& nums) {\n        int n = parents.size(), val = 2;\n        Values = vector <int>(n, 1);\n        Graph = vector <vector <int>>(n);\n        for (int i = 1; i < n; i++) {\n            Graph[parents[i]].push_back(i);\n        }\n        for (int i = 0; i < n; i++) {\n            if (nums[i] == 1) {\n                int idx = i;\n                while (idx != -1) {\n                    Set.insert(nums[idx]);\n                    DFS(idx, nums);\n                    while (Set.find(val) != Set.end()) val++;\n                    Values[idx] = val;\n                    idx = parents[idx];\n                }\n                break;\n            }\n        }\n        return Values;\n    }\n};\n```
['Depth-First Search', 'C']