I need to evaluate $\displaystyle \int \_0^\pi \frac{d\theta}{1+\sin^2(\theta)}$ by using Cauchy's integral formula, and the substitution $z = e^{i\theta}.$ So far, I have that 
$$d\theta = \frac{1}{iz}dz$$ and
$$1+\sin^2(\theta) = 1+ \frac{1}{4}\left(z^2 -2 +\frac{1}{z^2}\right) = \frac{1}{4}\left(4+ z^2 -2 +\frac{1}{z^2}\right) = \frac{1}{4}\left(2+ z^2 +\frac{1}{z^2}\right).$$

So the integral becomes

$$\int \frac{4dz}{iz \left(2+z^2+\frac{1}{z^2}\right)}= \int \frac{(4z)dz}{iz^4 +2iz^2+i}$$

Now, I'm not sure that last step was in the right direction, but it seems to me to be the only way I can factor the bottom so that I can apply Cauchy's integral formula. Now, the bottom factors as 
$$(z-i)^2(z+i)(iz-i).$$
However, I'm a bit confused about this factorization because I did it by polynomial division. But when I used the quadratic formula, I got that $z = -i$ is also a double root, which would imply that it factorizes as $$(z-i)^2(z+i)^2.$$ So first of all, can someone help me clear up this confusion? And second, I'm not quite sure where to be evaluating the integral because both of the singularities lie on the unit circle, and I am only supposed to integrate from $0$ to $\pi,$ so should I just take half of the integral from $0$ to $2\pi$? If this is not always possible, I'd appreciate a brief explanation as to why.