Refactor this duplicated code into a boolean test on IndexScanPlanNode called something like "predicatesAllowOptimizedAggregation()".