Test if two nodes in a binary search tree are cousins
The logic seems sane to me in general.

If the caller has the values to seek instead of node pointers, then you could change the function parameters to the value types and drop the a == nullptr || b == nullptr checks. But if the caller has node pointers that you cannot know for sure if null or not, then indeed you don't have a choice.

I find these statements more readable without the line breaks and unnecessary parentheses:

a_seek = a-&gt;value &lt; a_seek-&gt;value ? a_seek-&gt;left : a_seek-&gt;right;
b_seek = b-&gt;value &lt; b_seek-&gt;value ? b_seek-&gt;left : b_seek-&gt;right;