There are some problems with your end conditions. If the loop doesn't find the id, it must be detectable through the return value. Making it NULL in that case would be sensible. This can be done by making two changes: instead of setting p and doing break, return it directly (that way the for loop will only finish if the id is not found), and change return p at the end into return NULL.
Then when making the recursive call, you need to check the return value. If it was NULL, continue. Otherwise return it.
And the previous answer is correct that the check for the child id can better be removed, too, especially because it needs to (but doesn't) check for NULL.