This code sets found to true only if a record whose key is equal to keyvalue is in the binary search tree t. If found is true, then pred contains a pointer to the predecessor of that record, and p contains a pointer to that record. If found is false, then pred points to the node that would have been its predecessor had it been in the tree.
found = FALSE;
p = t;
pred = NULL;
while ((p != NULL) && (!found))
if (keyvalue == p->key)
found = TRUE;
else if (keyvalue < p->key)
{
pred = p;
p = p->leftptr;
}
else
{
pred = p;
p = p->rightptr:
}