On the genesis of nationalism