public Object visit(RelationalExpression node) {
            int operator = node.getOperator().getID();
            // "isa" and "!=" apply casts to "then" scope, "==" to "else".
            // The "isa" cast makes the type more specific, the "!=" cast makes
            // the type non-null, and the "==" cast makes the type non-null in
            // the "else" scope.
            boolean forThenPart = operator != Token.EQ;

            boolean typeKnown = true;

            if (mOpStack != null) {
                int length = mOpStack.length();
                for (int i=0; i<length; i++) {
                    switch (mOpStack.charAt(i)) {
                    case NOT_OP:
                        forThenPart = !forThenPart;
                        break;
                    case AND_OP:
                        if (!forThenPart) {
                            typeKnown = false;
                        }
                        break;
                    case OR_OP:
                        if (forThenPart) {
                            typeKnown = false;
                        }
                        break;
                    }
                }
            }

            if (!typeKnown) {
                return super.visit(node);
            }

            if (operator == Token.ISA) {
                TypeName typeName = node.getIsaTypeName();
                if (typeName != null) {
                    Expression left = node.getLeftExpression();
                    if (left instanceof VariableRef) {
                        Type type = typeName.getType();
                        if (type != null) {
                            addCast((VariableRef)left, type.toNonNull(),
                                    forThenPart);
                        }
                    }
                }
            }
            else if (operator == Token.EQ || operator == Token.NE) {
                VariableRef ref;
                Expression test;

                Expression left = node.getLeftExpression();
                Expression right = node.getRightExpression();

                if (left instanceof VariableRef) {
                    ref = (VariableRef)left;
                    test = right;
                }
                else if (right instanceof VariableRef) {
                    ref = (VariableRef)right;
                    test = left;
                }
                else {
                    ref = null;
                    test = null;
                }

                if (test != null &&
                    test.isValueKnown() && test.getValue() == null) {

                    Type type = ref.getType();
                    if (type != null) {
                        // If the expression "var != null" is true, then
                        // the the type becomes non-null.

                        if (!type.isNonNull()) {
                            addCast(ref, type.toNonNull(), forThenPart);
                        }
                    }
                }
            }

            return super.visit(node);
        }