Code Fragment: BST3



public:
  void insertItem(const Key& k, const Element& e)	// insert (key,element)
    { inserter(k, e); }
protected:
  BTPosition inserter(const Key& k, const Element& e) {	// insert utility
    BTPosition p = finder(k, T.root());			// find insertion spot
    while (T.isInternal(p))				// key already exists?
      p = finder(k, T.rightChild(p));			// look further
    T.expandExternal(p);				// add new node here
    setItem(p, BSTItem(k, e));				// store (key,element)
    return p;						// return this position
  }