... string removedsmallest(StringTree * & t) { if (t->left == NULL) { string answer = t->data; t = t->right; return answer; } else return removedsmallest(t->left); } void remove(StringTree * & t, string s) { if (t==NULL) return; else if (s == t->data) { if (t->left==NULL) t = t->right; else if (t->right==NULL) t = t->left; else t->data = removedsmallest(t->right); } else if (s < t->data) remove(t->left, s); else remove(t->right, s); } ... ... else if (command=="r") { string operand; cin >> operand; remove(tree, operand); cout << operand << " removed (if it was there)\n"; } ...