Gall wasps have a multi-approach solution to defend against their enemies
Scientists studying the life of insects have discovered that they may have diversified to limit predators.
The study, by researchers in Edinburgh and Reading, found that plant-eating bugs stuck to tiny neighbourhoods to cut the odds of being eaten.
Many have adapted to live only in specific circumstances, like on a leaf or root, at a particular time of year.
The results may explain the huge number of species of insects, which account for a large proportion of all life.
The study found that bugs which live in similar circumstances are often attacked by the same predatory insects.
However, while a predator may be able to overcome one obstacle, the chances of it doing so in all environments are remote.
The researchers believe this helps to explain why, for example, as many as 800 species of insects may be found in one English oak tree.
The study focused on gall wasps - tiny wasps that live in oak trees, in homes known as galls.
Each gall wasp lived in a particular type of structure or gall, in a specific place on a distinct type of oak at a certain time of year.
The different circumstances influenced which predators were able to attack.
Gall wasps' enemies have evolved counter-measures to some gall defences, but not all - with scientists describing it as an "evolutionary arms race" that has lasted for at least 40 million years.
Dr Graham Stone, of the University of Edinburgh's School of biological studies, said: "The diversity of insects on Earth is staggering, and one of the mysteries has been how so many species can survive essentially in the same place.
"Now we understand more about how these different species can coexist on a single tree.
"Our findings also shed light on how insects can use the plants on which they live for protection against their enemies."
The research was carried out by the University of Edinburgh, University of Reading and the Centre for Ecology and Hydrology, together with researchers in Hungary.
The study was funded by the Natural Environment Research Council and published in PLoS Biology.