func (t *Tree) Delete(id int32, n *Node) {
	if len(n.ids) > 1 {
		for k, v := range n.ids {
			if v == id {
				n.ids = append(n.ids[:k], n.ids[k+1:]...)
				fixup_size(n)
				return
			}
		}
	} else {  
		fixup_size(n)
		if n.left != nil && n.right != nil {
			pred := maximum_node(n.left)
			n.score = pred.score
			n.ids = pred.ids
			tmp := pred
			for tmp != n {
				tmp.size -= len(pred.ids)
				tmp = tmp.parent
			}
			n = pred
		}
		var child *Node
		if n.right == nil {
			child = n.left
		} else {
			child = n.right
		}
		if node_color(n) == BLACK {
			n.color = node_color(child)
			t.delete_case1(n)
		}
		t.replace_node(n, child)
		if n.parent == nil && child != nil {
			child.color = BLACK
		}
	}
}
---------------------------------------------------------- Delete an id from a node
WRITE-LOCK
package dos
import (
	"log"
	"strings"
)
const (
	RED   = true
	BLACK = false
)
type Node struct {
	left   *Node
	right  *Node
	parent *Node
	size  int  
	color bool
	score int32    
	ids   []int32  
}
func (n *Node) Ids() []int32 {
	return n.ids
}
func (n *Node) Score() int32 {
	return n.score
}
type Tree struct {
	root *Node
}
func (t *Tree) Clear() {
	t.root = nil
}
func (t *Tree) Root() *Node {
	return t.root
}
func (t *Tree) Count() int {
	if t.root != nil {
		return t.root.size
	}
	return 0
}
func _nodesize(n *Node) int {
	if n == nil {
		return 0
	}
	return n.size
}
func lookup_node(n *Node, rank int) (id int32, node *Node) {
	if n == nil {
		return -1, nil  
	}
	start := _nodesize(n.left) + 1
	end := _nodesize(n.left) + len(n.ids)
	if rank >= start && rank <= end {
		return n.ids[rank-start], n
	}
	if rank < start {
		return lookup_node(n.left, rank)
	}
	return lookup_node(n.right, rank-end)
}
func new_node(score int32, id int32, color bool, left, right *Node) *Node {
	n := Node{score: score, color: color, left: left, right: right, size: 1, ids: []int32{id}}
	return &n
}
func (t *Tree) Rank(rank int) (id int32, node *Node) {
	return lookup_node(t.root, rank)
}
func (t *Tree) _lookup_score(score int32) (rank int, n *Node) {
	n = t.root
	if n == nil {
		return -1, nil
	}
	base := 0
	for n != nil {
		if score == n.score {
			rank = base + _nodesize(n.left) + 1  
			return rank, n
		} else if score > n.score {
			n = n.left
		} else {
			base += _nodesize(n.left) + len(n.ids)
			n = n.right
		}
	}
	return -1, nil
}
func (t *Tree) Locate(score int32, id int32) (int, *Node) {
	rank, node := t._lookup_score(score)
	if node == nil {  
		return -1, nil
	}
	for k, v := range node.ids {
		if v == id {
			return rank + k, node
		}
	}
	return -1, nil
}
func (t *Tree) Insert(score int32, id int32) {
	inserted_node := new_node(score, id, RED, nil, nil)
	if t.root == nil {
		t.root = inserted_node
	} else {
		n := t.root
		for {
			n.size++               
			if score == n.score {  
				n.ids = append(n.ids, id)
				return
			} else if score > n.score {  
				if n.left == nil {
					n.left = inserted_node
					break
				} else {
					n = n.left
				}
			} else if score < n.score {  
				if n.right == nil {
					n.right = inserted_node
					break
				} else {
					n = n.right
				}
			}
		}
		inserted_node.parent = n
	}
	t.insert_case1(inserted_node)
}