Tiny function to ensure a node of a BST has a valid relationship with its children
Which of my two versions is more pleasant and readable?


The second is just bad as said in the comment by JK01.

It should be just

return !(hasLeft() &amp;&amp; left.compareTo(this) &gt; 0 ||
    hasRight() &amp;&amp; right.compareTo(this) &lt; 0);


and then you could use De-Morgan rule to get rid of the outer negation. However, something like

return (!hasLeft() || left.compareTo(this) &lt;= 0) &amp;&amp;
    (!hasRight() || right.compareTo(this) &gt;= 0);


has nothing to do with the idea it represents. Sticking with the original and adding braces is best:

private boolean nodeIsValid() {
    if (hasLeft() &amp;&amp; left.compareTo(this) &gt; 0) {
        return false;
    }
    if (hasRight() &amp;&amp; right.compareTo(this) &lt; 0) {
        return false;
    }
    return true;
}



It's easily extensible: Just add another condition.
It's structured: 2 simple expressions instead of a multiline monster.
It corresponds exactly with what could go wrong.