Followup r74847, reduce some more duplication by moving the foreach() logic to a...