Minor change for this if block. Do this instead:

    if (!expression.evaluate(tuple,ptr)) {
        return false;
    }
    if (ptr.getLength() == 0) {
        return true; // expression was evaluated, but evaluated to null
    }