AST: improved 'incorrect logic' checking when there are nested expressions