Refactor out this loop snippet since all langs will likely need it.