Is it possible to mod this as the primary succession without having an automatic game loss? The heir essentially is the courtier with the highest age+prestige score and it usually would be one of your children as they are nobles and would get boost from minor titles and a fraction of your dynasty total. Though I suppose an older councilor might end up getting "elected" if they have enough prestige to surpass your children.