Make sure node is defined before continuing.
Cleanup nested if statements.