I have an assignment where I have to write several methods for a binary search tree. The node for the binary search tree has two sets of data, a name and a correlating weight. The tree is sorted by names. I am having trouble with one of the requirements for a method. The method is to search for a name entered by the user and return the weight of that person if found. If not found, the method is to return an error message. I am having trouble with the error message component. I was only able to come up with solutions where an error message was printed several times because the method is recursive. I would appreciate it if anyone could point me in the right direction.
I've included the node class and method down below. The search method does not include the error component.