subtle optimization for RepeatedExpression._sanity function