Binary Tree to Sum Tree Transformation

Original Binary Tree
Sum Tree
What is a Sum Tree?
In a Sum Tree, the value of each node is equal to the sum of all the values in its left and right subtrees. If a node has no children, its sum tree value is 0 (as there are no subtrees to sum).