code: func (t *BTree) ReplaceOrInsert(item Item) Item {
  	if item == nil {
  		panic("nil item being added to BTree")
  	}
  	if t.root == nil {
  		t.root = t.cow.newNode()
  		t.root.items = append(t.root.items, item)
  		t.length++
  		return nil
  	} else {
  		t.root = t.root.mutableFor(t.cow)
  		if len(t.root.items) >= t.maxItems() {
  			item2, second := t.root.split(t.maxItems() / 2)
  			oldroot := t.root
  			t.root = t.cow.newNode()
  			t.root.items = append(t.root.items, item2)
  			t.root.children = append(t.root.children, oldroot, second)
  		}
  	}
  	out := t.root.insert(item, t.maxItems())
  	if out == nil {
  		t.length++
  	}
  	return out
  }
docs: // ReplaceOrInsert adds the given item to the tree.  If an item in the tree
  // already equals the given one, it is removed from the tree and returned.
  // Otherwise, nil is returned.
  //
  // nil cannot be added to the tree (will panic).