The last two snippets of code are not equivalent.
The second if in the second piece of code should be:
if (condition && !anotherCondition) {The second if in the second piece of code should be:
if (condition && !anotherCondition) {