public TreapNode Merge(TreapNode other) { if (other == null) { return(this); } if (PriorityOver(other)) { if (this.right == null) { this.right = other; } else { this.right = this.right.Merge(other); } Update(); return(this); } else { //no need to check if left is null other.left = this.Merge(other.left); other.Update(); return(other); } }