There are quite a lot of diversity in behaviors of animals and lesser organisms, like mating, hunting, feeding, hiding and avoiding predators.
At the same time I know that many hormones like melatonin are present in a variety of organisms.
This makes me interested if animal behaviors did all arise and specialized independently, or did all behavior arise from some primitive response that some "common ancestor" possessed ?
For example, a primitive organism has no concept of predators and can only feed and procreate. Slowly, a predator appears in the ecosystem. Over time, how would the "escape predator" behavior appear in such organism? Would the mating behavior be modified for defense?