func delete(x0 *Table, w int, sl []int, a uint64, pl int) (r Route, ok bool) {
	x := x0
	xsv := [maxLevel]*Table{0: x}  
	ss := 0                        
	var s uint64                   
	level := 0
	var i uint64              
	var isv [maxLevel]uint64  
	if a == 0 && pl == 0 {
		if r = x.r[1]; r == nil {
			return nil, false
		}
		x.r[1] = nil
		return r, true
	}
	for {
		ss += sl[level]
		s = (a >> (w - ss)) & ((1 << sl[level]) - 1)
		if pl <= ss {
			break
		}
		i = fringeIndex(sl[level], s)
		isv[level] = i
		if x.n[i] == nil {
			return nil, false
		}
		xsv[level] = x
		x = x.n[i]
		level++
	}
	ss -= sl[level]
	r, ok = x.deleteSingleLevel(RouteParams{Width: sl[level], Addr: s, Len: pl - ss})
	if !ok {
		return nil, false
	}
	x.ref--
	if level > 0 && x.ref == 0 {
		for {
			x.free()
			level--         
			x = xsv[level]  
			x.ref--
			if level == 0 || x.ref > 0 {
				break
			}
		}
	}
	return r, true
}
delete is multi-level deletion (Algorithm 6)

w: address length
sl: stride length by level
a: destination address
pl: prefix length

It returns the deleted route and whether it was successful.
package art
func baseIndex(width int, addr uint64, prefixLen int) uint64 {
	return (addr >> uint64(width-prefixLen)) + (1 << uint64(prefixLen))
}
func fringeIndex(width int, addr uint64) uint64 {
	return baseIndex(width, addr, width)
}
type Route interface {
	RouteParams() RouteParams
}
type RouteParams struct {
	Width int     
	Addr  uint64  
	Len   int     
}
func (p RouteParams) baseIndex() uint64 { return baseIndex(p.Width, p.Addr, p.Len) }
type Table struct {
	w  int    
	sl []int  
	r         []Route
	n         []*Table  
	ref       int       
	parentPtr **Table   
}
func (x *Table) free() {
	if x.parentPtr != nil {
		*x.parentPtr = nil
		x.parentPtr = nil
	}
}
func (x *Table) clone() *Table {
	if x == nil {
		return nil
	}
	x2 := &Table{
		w:         x.w,
		sl:        x.sl,
		ref:       x.ref,
		r:         x.r,
		parentPtr: x.parentPtr,
	}
	if x.n != nil {
		x2.n = make([]*Table, len(x.n))
		for i, v := range x.n {
			x2.n[i] = v.clone()
		}
	}
	return x2
}
func NewTable(stride int) *Table {
	n := 1 << (stride + 1)
	return &Table{
		r: make([]Route, n),
		n: make([]*Table, n),
	}
}
func (x *Table) allot(smallestFringeIndex uint64, b uint64, q, r Route) {
	t := smallestFringeIndex
	if x.r[b] == q {
		x.r[b] = r
	} else {
		return
	}
	if b >= smallestFringeIndex {
		return
	}
	b = b << 1
	x.allot(t, b, q, r)  
	b++
	x.allot(t, b, q, r)  
}
func (x *Table) insertSingleLevel(r Route) bool {
	return x.insertSingle(r.RouteParams(), r)
}
func (x *Table) insertSingle(rp RouteParams, r Route) bool {
	b := rp.baseIndex()
	xb := x.r[b]
	if xb != nil {
		xbP := xb.RouteParams()
		if rp.Addr == xbP.Addr && rp.Len == xbP.Len {
			return false  
		}
	}
	x.allot(uint64(1)<<rp.Width, b, xb, r)
	return true
}
func (x *Table) Insert(r Route) bool {
	rp := r.RouteParams()
	return insert(x, rp.Width, x.sl, r)
}
func insert(x0 *Table, w int, sl []int, r Route) bool {
	level := 0
	ss := 0  
	x := x0  
	rp := r.RouteParams()
	if rp.Addr == 0 && rp.Len == 0 {
		if x.r[1] != nil {
			return false  
		}
		x.r[1] = r  
		return true
	}
	var s uint64  
	for {
		ss += sl[level]
		s = (rp.Addr >> (rp.Width - ss)) & ((1 << sl[level]) - 1)
		if rp.Len <= ss {
			break
		}
		i := fringeIndex(sl[level], s)
		if x.n[i] == nil {
			child := NewTable(sl[level+1])  
			x.n[i] = child
			child.parentPtr = &x.n[i]
			x.ref++
		}
		x = x.n[i]
		level++
	}
	ss -= sl[level]
	if x.insertSingle(RouteParams{Width: sl[level], Addr: s, Len: rp.Len - ss}, r) {
		x.ref++  
		return true
	}
	return false
}
func (x *Table) lookupSingleLevel(addr uint64) (r Route, ok bool) {
	r = x.r[fringeIndex(x.w, addr)]
	return r, r != nil
}
func (x *Table) Lookup(addr uint64) (r Route, ok bool) {
	r = searchMultiLevel(x, x.w, x.sl, addr)
	return r, r != nil
}
func searchMultiLevel(x0 *Table, w int, sl []int, a uint64) (r Route) {
	lmr := x0.r[1]  
	x := x0
	ss := 0  
	var s uint64
	level := 0
	var i uint64  
	for {
		ss += sl[level]
		s = (a >> (w - ss)) & ((1 << sl[level]) - 1)
		i = fringeIndex(sl[level], s)
		if x.n[i] != nil {
			if x.r[i] != nil {
				lmr = x.r[i]
			}
			x = x.n[i]
			level++
		} else if x.r[i] != nil {
			return x.r[i]
		} else {
			return lmr  
		}
	}
}
func (x *Table) deleteSingleLevel(rp RouteParams) (deleted Route, ok bool) {
	b := rp.baseIndex()
	prev := x.r[b]
	if prev == nil {
		return nil, false
	}
	x.allot(uint64(1)<<rp.Width, b, prev, x.r[b>>1])
	return prev, true
}
const maxLevel = 8
func (x *Table) Delete(rp RouteParams) (deleted Route, ok bool) {
	return delete(x, rp.Width, x.sl, rp.Addr, rp.Len)
}