Response validation with for loop into Galting

How to put response validation into Gatling.

into response there is jsonarray of offerId

I have a logic that if offerId of 1st array is null then go to second array.

.check(jsonPath("$.Response.OffersGroup.CarrierOffers[0].Offer[1].OfferItem[1].OfferItemID").find.saveAs(“OfferItemId”))

here instead of 1 i want to use i tried as below

.check(jsonPath("$.Response.OffersGroup.CarrierOffers[0].Offer[1].OfferItem[1].OfferItemID").find.saveAs(“OfferItemId”))

.exec(session =>{

if(OfferItemId == NULL)//here need to check if its null then go to the next array.
It means for example $.Response.OffersGroup.CarrierOffers[0].Offer[1].OfferItem[1].OfferItemID is null
then it will be go
$.Response.OffersGroup.CarrierOffers[0].Offer[2].OfferItem[1].OfferItemID

session})

Through java I can do but for Gatling

if(Response.OfferId(i) != NULL)
{
OfferId = Response.OfferId(i);

break;
}