ENH: Improved if scoping test to check whether the variable goes out of scope after the if statement.