Iterate over collection in batches if functionality is provided, otherwise normal iteration.