When you read an article like "List of rulers of Morocco" the list includes the historical precursors to the modern state. These precursors include to some extend the same territory but the make up of the people can be really different.
The Idrisid, the Almoravid, the Almohad, the Maranid and the Wattasid dynasties were Berber. Many of them were Shia muslims. Contrast that with the later Arab dynasties and a country that is predominantly Sunni.
It is relevant because it does not make sense to state that an Idrisid ruler is a "Morocon head of state". The question is very much how did the Idrisids or any of the other dynasties call their country because that is what they were ruling.
Another thing to consider is what happens when a country is conquered. It does not make sense to suggest that there is some kind of succession. The reality is that both the dynasty and the country become irrelevant as they are absorbed by the conquering nation.
What is obvious to me is that many of the solutions as used in Wikipedia are based on template logic. With Wikidata we have the opportunity to come up with better solutions. What they will be is not immediately obvious.