func (bkd *BkdTree) Compact() (err error) {
	bkd.rwlock.RLock()
	if !bkd.open {
		bkd.rwlock.RUnlock()
		return
	}
	k := bkd.getMaxCompactPos()
	bkd.rwlock.RUnlock()
	if k < 0 {
		return
	}
	bkd.rwlock.Lock()
	err = bkd.compactTo(k)
	bkd.rwlock.Unlock()
	return
}
Compact comopact subtrees if necessary.
package bkdtree