On the evolution of egg placement and gregariousness of caterpillars in the Lepidoptera