# Merge Trees (Leetcode 617)

Problem Link: <https://leetcode.com/problems/merge-two-binary-trees/>

```python
class Solution:
    def mergeTrees(self, root1: Optional[TreeNode], root2: Optional[TreeNode]) -> Optional[TreeNode]:
        
        if(root1 is None and root2 is None):
            return None
        elif(root1 is None):
            return root2
        elif(root2 is None):
            return root1
        elif(root1 is not None and root2 is not None):
            root1.val=root1.val+root2.val
            l=self.mergeTrees(root1.left,root2.left)
            r=self.mergeTrees(root1.right,root2.right)
            root1.left=l
            root1.right=r
            return root1
```
