```
class Solution {
public:
int findSecondMinimumValue(TreeNode* root) {
collect(root);
if(nums.size() == 1){
return -1;
}
vector<int> arr(nums.begin(), nums.end());
sort(arr.begin(), arr.end());
return arr[1];
}
private:
void collect(TreeNode *root){
nums.insert(root->val);
if(root->left)collect(root->left);
if(root->right)collect(root->right);
}
set<int> nums;
};
```