The cultural evolution of shamanism