Deleting node from binary search tree

I'm not sure how to go about asking this... I need to delete a node. What I have works on a specific data set, but not another. I read in two data sets as follows;

A 28 A 19 A 34 A 2 R 2 A 51 A 28 R 16 R 19 P

This returns: 2 this is the item being removed 28 has already been added to the list 16 this is the item being removed 19 this is the item being removed 28 34 51 ** the prints are to test, the actual output would be the last line.

The second data set is; A 11 A 21 A 31 A 41 A 51 R 11 A 11 A 21 R 31 R 41 P

This output is; 11 this is the item being removed Something is wrong! 11 has already been added to the list 21 has already been added to the list 31 this is the item being removed 41 this is the item being removed 11 21 31 41 51

It would be a good idea to put code tags around your code to make it more readable.

You are not giving all the relevant code, but. - You can get the error message only when pp is null - it is only set in the while loop (in the visible code) - therefore you don't get into the while loop - check what happens when you remove the root element (is 11 the root element in the second case?).