John of St. Thomas wrote (here he describes the issue of occult heresy regarding a Pope as well as the two conditions that are needed in order to depose a Pope for heresy):
Two Conditions
"But we need to know if the Pope can be deposed in any case of heresy and in whatever form of being a heretic.; or if some additional conditions are needed without which heresy alone is not sufficient to depose the Pontiff.
I answer that the Pontiff cannot be deposed and lose his pontificate except if two conditions are fulfilled together:
1) That the heresy is not hidden, but publicly and legally notorious;
2) then that he must be incorrigible and pertinacious in his heresy.
If both conditions are fulfilled the Pontiff may be deposed, but not without them; and even if he is not unfaithful interiorly, however if he behaves externally as a heretic, he can be deposed and the sentence of deposition will be valid.
Concerning the first requirement, among some Catholics are of a different opinion, saying that even for occult heresy [Editor: occult = "hidden," "not visible"], the Pontiff loses his Papal jurisdiction, which is based on the true Faith and right confession of Faith; supporting this opinion we have Torquemada (1,2p. from v. 18 and 1. 2, c. 102) Paludanus, Castro, Simancus, Driedo […]
Others think that it is necessary that the heresy must be external and proved in the external forum in order that the Pontiff can be deposed of the pontificate; thus Soto (4 sent. D. 22 q.2.2); Cano (from Locis 1.4), who believes that the contrary opinion is not even probable; Catejan (On the pope's power, De Comparatione auctoritatis papae and concilii cuм apologia eiusdem tractatus, Rome, Angelicuм, 1936; c.18 and 19), Suarez, Azorius, Bellarmine (On the Roman Pontiff, c.30).
The principle is that occult heretics, as long as they are not condemned by the Church and being separated [by her] belong to the Church and are in communion with her, as like being moved from the exterior, even if they do not receive any more interiorly the vital movement; therefore, the Pontiff, if he is an occult heretic, is not separated from the Church; therefore, he can still be the head, since he is still a part and a member, even if he is not a living one.
A confirmation of it is that priests of a lower order can exercise the power of order and jurisdiction without Faith because a heretical priest can confer the sacraments in cases of extreme need […]
The second condition, in order to be able to depose the Pope, namely that he is guilty of incorrigible and pertinacious heresy, is evident, because if someone is ready to be corrected and is not pertinacious in heresy, is not considered to be heretical (Decree of Gratian, No. 24. 3. 29 "Dixit Apostolus"); therefore, if the Pope is ready to be corrected, he should not be deposed as a heretic.
The Apostle [Paul] prescribes to avoid heretics only after a first and second correction: if he comes to repentance after the correction, he should not be avoided; therefore, as the Pope must be deposed for heresy under this apostolic precept, it follows that if he can be corrected, he should not be deposed."
http://www.dominicansavrille.us/on-the-deposition-of-the-pope-part-1-of-2/