class Solution(object):
def findSecondMinimumValue(self, root):
"""
:type root: TreeNode
:rtype: int
"""
if not root:
return -1
temp = []
stack = [root]
while stack:
sizestack = len(stack)
for i in range(sizestack):
node = stack.pop(0)
temp.append(node.val)
if node.left:
stack.append(node.left)
if node.right:
stack.append(node.right)
temp.sort()
return list(set(temp))[1] if len(set(temp)) > 1 else -1