recursive caterpillar