Damn it CK2. I really, really wish there was some kind of tool/map mode for "What would happen if I died today." Started a new game in 1066 as Galicia. Married an Italian duchess, and after a long and battle-filled life, I had conquered Leon and Castille. I figured it would be for my heirs to begin the push against the infidels to the south.
First, my Italian duchess wife dies, leaving her Italian lands to my two elder sons (a third I had used free-investitture to get out of the line). I guess? because those Italian lands made the HRE their liege, I immediately lost one of my richest Spanish provinces to my favored second son, now a count in the HRE. Remembering I've got to do something about having two sons and gavelkind succession (apparently you can't name your first son a successor to a bishop?), I get elective succession passed so I don't have to deal with Gavelkind. I'm the only voter, I've got a ton of titles and can't for some reason give any of them away. So that happens, and I die.
And all of a sudden the kingdoms of Castille and Leon are resussicated, and led by random cousins! On the plus side, the HRE was no longer a liege lord of anyone in my dynasty (not sure how that works). On the minus side, I've got to spend another generation reassembling the lands I had already conquered. Some quick movement and stabby-stabby quickly took care of Leon, and when the re-conquest of Castille bogged down, I called in the HRE, so it should fall soon as well - BUT STILL. Where the hell did that succession come from?