Can't you just do
while (rootp != NULL)
tdelete(rootp, &rootp, compar);
where, of course, compar() must be defined as usual for the tree
Note that the macros in sys/tree.h, which are available under the
liberal ISC (BSD) license and documented in tree(3), are usually
preferable to tsearch() and friends.