Remove the ancestor iteration logic with a while loop to reduce allocation count.
Remove the ancestor iteration logic with a while loop to reduce allocation count.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=257090283

monetate/closure-compiler,ChadKillingsworth/closure-compiler,google/closure-compiler,Yannic/closure-compiler,google/closure-compiler,ChadKillingsworth/closure-compiler,Yannic/closure-compiler,google/closure-compiler,ChadKillingsworth/closure-compiler,nawawi/closure-compiler,monetate/closure-compiler,monetate/closure-compiler,Yannic/closure-compiler,vobruba-martin/closure-compiler,vobruba-martin/closure-compiler,vobruba-martin/closure-compiler,vobruba-martin/closure-compiler,google/closure-compiler,Yannic/closure-compiler,ChadKillingsworth/closure-compiler,nawawi/closure-compiler,nawawi/closure-compiler,monetate/closure-compiler,nawawi/closure-compiler