Trigonometric Integral - Complex Integration Exercise :
If $a \in \mathbb R-\{0\}, |a|<1$, calculate the integral and show that :
$$\int_0^\pi \frac{\cos n\theta}{1 + a\cos \theta}d\theta = \frac{\pi}{\sqrt{1-a^2}}\Bigg(\frac{\sqrt{1-a^2} -1}{a} \Bigg)^n$$
Attempt :
Since $\cos \theta$ is even, we have :
$$\int_0^\pi \frac{\cos n\theta}{1 + a\cos \theta}d\theta = \frac{1}{2}\int_{-\pi}^\pi \frac{\cos n\theta}{1 + a\cos \theta}d\theta$$ 
We substitute $\cos n\theta = \Re(e^{in\theta})$ and we get :
$$\int_0^\pi \frac{\cos n\theta}{1 + a\cos \theta}d\theta = \frac{1}{2}\int_{-\pi}^\pi \frac{\cos n\theta}{1 + a\cos \theta}d\theta = \frac{1}{2}\Re\Bigg(\int_{-\pi}^\pi \frac{e^{in\theta}}{1 + a\cos \theta}d\theta \Bigg) $$ 
Now, I understand that a contour integral can be made around the unit circle $|z|=1$ and find the singularities to work with residues, but I cannot seem how to move one with this procedure.
I would really appreciate a thorough solution or some hints on how to get to the answer.

Let $z=e^{i\theta}$ and then
\begin{eqnarray}
&&\int_0^\pi \frac{\cos n\theta}{1 + a\cos \theta}d\theta\\
& =& \frac{1}{2}\int_{-\pi}^\pi \frac{\cos n\theta}{1 + a\cos \theta}d\theta\\
&=&\frac12\int_{|z|=1}\frac{\frac{z^n+\frac1{z^n}}{2}}{1+a\frac{z+\frac1z}{2}}\frac1{iz}dz\\
&=&\frac1{2i}\int_{|z|=1}\frac{z^{2n}+1}{z^n(2z+a(z^2+1))}dz\\
&=&\frac1{2ai}\int_{|z|=1}\frac{z^{2n}+1}{z^n(z-z_1)(z-z_2)}dz\\
&=&\frac1{2ai}2\pi i\bigg[\textbf{Res}\bigg(\frac{z^{2n}+1}{z^n(z-z_2)},z=z_1\bigg)+\textbf{Res}\bigg(\frac{z^{2n}+1}{z^n(z-z_1)(z-z_2)},z=0\bigg)\bigg]\\
&=&\frac{\pi}{a}\bigg[\frac{z_1^{2n}+1}{z_1^n(z_1-z_2)}+\frac{z_1^n-z_2^n}{z_1^nz_2^n(z_1-z_2)}\bigg]\\
&=&\frac{\pi}{a}\frac{1+z_1^nz_2^n}{(z_1-z_2)z_2^n}\\
&=&\frac{\pi}{\sqrt{1-a^2}z_2^n}
\end{eqnarray}
where
$$z_1=\frac{-1+\sqrt{1-a^2}}{a},z_2=\frac{-1-\sqrt{1-a^2}}{a}. $$
