Excommunication can also be used to conveniently take care of ambitious vassals since you can execute imprisoned excommunicated characters without penalty. Ask the pope to excommunicate one of your vassals, imprison them and then execute and allow their (more loyal) heir to take over. As an added bonus, if they rebel while you're trying to imprison them, you can revoke one of their titles if need be after beating them and then execute them. The heir's opinion is unaffected even though you just lopped of his daddy's head and stole one of his titles.