I solved my issue! I followed the example on
I added a Boolean inside the nested for each, if statement
found = true, and added a break to break out of the inner most foreach loop
I then added another if statement inside the 1st foreach loop where
found = false
add data row.

