I'm trying to implement Binary Search tree in python using recursion. I got trapped in some infinite recursions happening in my program.I'm making recursive calls to the function RecursBST by passing address and the data until the top traverse down to None value of either it's left or right child.
class createnode:
    def __init__(self,data):
        self.root=data
        self.left=None
        self.right=None
class createbinarysearchtree:
    def __init__(self, data = None):
        self.top=None   
    def RecursBST(self,top,data):            
        if self.top is None:
            self.top=createnode(data)                
        elif  self.top.root>data:
            self.top.left=self.RecursBST(self.top.left,data)
        elif  self.top.root<data:
            self.top.right=self.RecursBST(self.top.right,data)
conv=createbinarysearchtree();
conv.RecursBST(conv.top,50)
conv.RecursBST(conv.top,40)
I ran to the below error :
 self.top.left=self.RecursBST(self.top.left,data)
RuntimeError: maximum recursion depth exceeded
 
    
 
     
     
    