<reponame>ZintrulCre/LeetCode_Archiver<filename>LeetCode/python3/965.py
class Solution:
    value = 0

    def isUnivalTree(self, root):
        """
        :type root: TreeNode
        :rtype: bool
        """
        if not root:
            return True
        return self.CompareValue(root, root.val)

    def CompareValue(self, root, value):
        if not root:
            return True
        if root.val != value:
            return False
        return self.CompareValue(root.left, value) and self.CompareValue(root.right, value)
class Solution:
    value = 0

    def isUnivalTree(self, root):
        """
        :type root: TreeNode
        :rtype: bool
        """
        if not root:
            return True
        return self.CompareValue(root, root.val)

    def CompareValue(self, root, value):
        if not root:
            return True
        if root.val != value:
            return False
        return self.CompareValue(root.left, value) and self.CompareValue(root.right, value)
:type root: TreeNode         :rtype: bool