Python Straightforward recursion
\nclass Solution:\n    \n    def averageOfSubtree(self, root: Optional[TreeNode]) -> int:\n        self.count = 0\n        def recursion(node):\n            if 
```\nclass Solution:\n    \n    def averageOfSubtree(self, root: Optional[TreeNode]) -> int:\n        self.count = 0\n        def recursion(node):\n            if node == None:\n                return [0, 0]\n            val = node.val\n            left = recursion(node.left)\n            right = recursion(node.right)\n            left_val, left_num = left[0], left[1]\n            right_val, right_num = right[0], right[1]\n            val += left_val\n            val += right_val\n            if node.val == val // (left_num + right_num + 1):\n                self.count += 1\n            return [val, left_num + right_num + 1]\n        recursion(root)\n        return self.count\n```
['Python']