The popes in the Middle Ages were actually Catholic despite any shortcomings, sins, etc. None were manifest heretics.
Although this certainly depends on how one defines the word "heretic" and the phrase "middle ages", a good case can be made that there is historical precident. Two good articles on the topic are below. The second article provides the best description of the current situation I have read.