Depends what you mean by “worked”. It prevented the emergence of priest kings quite well. Not allowing legitimate sons puts a major crimp in anyone’s plans to turn a religious organization’s land into their personal property. See how the Teutonic order turned into Brandenburg upon Protestantisation.
The Pope was a priest king for centuries not to mention the smattering of Bishop/Cardinal led mini statesi n the HRE.