Carrano (1st edition), pp. 546-547    Next Slide

retrieveItem (ttTree, searchKey)
// Returns from the nonempty 2-3 tree ttTree the
// item whose search key equals searchKey.  The operation
// fails and returns null if no such item exists.
.
.  if ( searchKey is in ttTree's root node r )
.  {  // the item has been found
.  .  return the data portion of r
.  }
.
.  else if ( r is a leaf )
.     return null   // failure
.
.  else if ( r has two data items )
.  {   if ( searchKey < smaller search key of r )
.  .      return retrieveItem(r's left child, searchkey)
.  .   else if ( searchKey < larger search key of r )
.  .      return retrieveItem(r's middle child, searchkey)
.  .   else
.  .      return retrieveItem(r's right child, searchkey)
.  }
.
.  else
.  {   if ( searchKey < smaller search key of r )
.  .      return retrieveItem(r's left child, searchkey)
.  .   else
.  .      return retrieveItem(r's right child, searchkey)
.  }