Taking care of free shipping cart rule when setting "Best Price" flag

Prerequesite :
You have a Cart rule with free shipping that applies.

Before :
The "Best Price" flag can be on a non-free carrier, instead of being on the free ones.

After :
If at least one free carrier is in the list, it will has the "Best Price" flag.
Hi,

I believe something is missing here, otherwise the foreach belo wwill be executed jus one time.

Regards