[dart2js] Replace recursion with loop
[dart2js] Replace recursion with loop

This does not fix #42641, but removes a recursion that can make #42641
look different.

Change-Id: Id070cea0eb10501f1750b2719ed710a938170038
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221480
Reviewed-by: Mayank Patke <e0355b78204b67a55a952941c68c8f1b40235938@google.com>
Commit-Queue: Stephen Adams <60cb5b73b7e0cb7dcda53302da4fab6ecfc7fa8b@google.com>

dart-lang/sdk,dart-lang/sdk,dart-lang/sdk,dart-lang/sdk,dart-lang/sdk,dart-lang/sdk,dart-lang/sdk,dart-lang/sdk