Caterpillar iteration alg