func (n *node) findLeafItemBin(cell uint64) int {
	i, j := 0, len(n.items)
	for i < j {
		h := i + (j-i)/2
		if cell >= n.items[h].cell {
			i = h + 1
		} else {
			j = h
		}
	}
	return i
}
findLeafItemBin position where the return value is the index for
inserting a new cell into the items array.
Optimized for binary searching
package celltree
const (
	numBits  = 7    
	numNodes = 128  
)
const (
	maxItems = 256                  
	minItems = maxItems * 40 / 100  
)
type item struct {
	cell uint64
	data interface{}
}
type node struct {
	branch bool    
	items  []item  
	nodes  []node  
	count  int     
}
type Tree struct {
	count int    
	root  *node  
}
func (tr *Tree) Count() int {
	return tr.count
}
func cellIndex(cell uint64, bits uint) int {
	return int(cell >> bits & uint64(numNodes-1))
}
func (tr *Tree) InsertOrReplace(
	cell uint64, data interface{},
	cond func(data interface{}) (newData interface{}, replace bool),
) {
	if tr.root == nil {
		tr.root = new(node)
	}
	if tr.root.insert(cell, data, 64-numBits, cond) {
		tr.count++
	}
}
func (tr *Tree) Insert(cell uint64, data interface{}) {
	tr.InsertOrReplace(cell, data, nil)
}
func (n *node) splitLeaf(bits uint) {
	n.branch = true
	n.count = 0
	n.nodes = make([]node, numNodes)
	for i := 0; i < len(n.items); i++ {
		n.insert(n.items[i].cell, n.items[i].data, bits, nil)
	}
	n.items = nil
}
func maxDepth(bits uint) bool {
	return bits < numBits
}
func (n *node) insert(
	cell uint64, data interface{}, bits uint,
	cond func(data interface{}) (newData interface{}, replace bool),
) (inserted bool) {
	if !n.branch {
		atcap := !maxDepth(bits) && len(n.items) >= maxItems
	insertAgain:
		if atcap && cond == nil {
			n.splitLeaf(bits)
			n.insert(cell, data, bits, nil)
			n.count--
		} else {
			if len(n.items) == 0 || n.items[len(n.items)-1].cell < cell {
				if atcap {
					cond = nil
					goto insertAgain
				}
				n.items = append(n.items, item{cell: cell, data: data})
			} else {
				index := n.findLeafItemSeqIns(cell)
				if cond != nil {
					for i := index - 1; i >= 0; i-- {
						if n.items[i].cell != cell {
							break
						}
						newData, replace := cond(n.items[i].data)
						if replace {
							n.items[i].data = newData
							return false
						}
					}
					if atcap {
						cond = nil
						goto insertAgain
					}
				}
				n.items = append(n.items, item{})
				copy(n.items[index+1:], n.items[index:len(n.items)-1])
				n.items[index] = item{cell: cell, data: data}
			}
		}
	} else {
		index := cellIndex(cell, bits)
		if !n.nodes[index].insert(cell, data, bits-numBits, cond) {
			return false
		}
	}
	n.count++
	return true
}
func (n *node) findLeafItemSeqIns(cell uint64) int {
	for i := len(n.items) - 1; i >= 0; i-- {
		if cell >= n.items[i].cell {
			return i + 1
		}
	}
	return 0
}