1. # Definition for a binary tree node.
    2. # class TreeNode:
    3. # def __init__(self, val=0, left=None, right=None):
    4. # self.val = val
    5. # self.left = left
    6. # self.right = right
    7. class Solution:
    8. def insertIntoBST(self, root: TreeNode, val: int) -> TreeNode:
    9. if root == None:
    10. return TreeNode(val = val)
    11. if val < root.val:
    12. root.left = self.insertIntoBST(root.left, val)
    13. else:
    14. root.right = self.insertIntoBST(root.right, val)
    15. return root