def METHOD_NAME(self, side, node):
    node.parent = self
    nodeSize = node.size()
    if side == "left":
        self.left = node
        self.weight = nodeSize
    elif side == "right":
        self.right = node
    tmp = self
    while tmp.parent:
        if tmp.parent.left == tmp:
            tmp.parent.weight += nodeSize
        tmp = tmp.parent