Why is your gpafind function trying to modify the tree? E.g.

q->right=gpafind(a,q->right);
surely you want the result of the call to just reflect the result of the subcall?