Don't do a cast, but instead do this:

    Expression child = children.get(i);
    child.evaluate(null, ptr);