```
class Solution {
public:
int findSecondMinimumValue(TreeNode* root) {
return dfs(root,root->val);
};
private:
int dfs(TreeNode *root,int first)
{
if(!root) return -1;
if(root->val != first) return root->val;
int left = dfs(root->left,first);
int right = dfs(root->right,first);
if(left == -1) return right;
if(right == -1) return left;
return min(left,right);
}
};
```