Heun functions and diagonals of rational functions (unabridged version)