'Perform cleanup on object deletion.'

def cleanup(self):

    self.op_tree = None
    self.grad_op_tree = None
    self.ad = None
    if (self.left is not None):
        self.left.cleanup()
    self.left = None
    if (self.right is not None):
        self.right.cleanup()
    self.right = None
