  Let $G$ be a connected reductive affine algebraic group defined over the
complex numbers, and $K\subset G$ be a maximal compact subgroup. Let $X , Y$ be
irreducible smooth complex projective varieties and $f: X \rightarrow Y$ an
algebraic morphism, such that $\pi_1(Y)$ is virtually nilpotent and the
homomorphism $f_* : \pi_1(X) \rightarrow\pi_1(Y)$ is surjective. Define $$
{\mathcal R }^f(\pi_1(X),\, G)\,=\, \{\rho\, \in\, \text{Hom}(\pi_1(X),\, G)\,
\mid\, A\circ\rho \ \text{ factors through }~ f_*\}\, , $$ $$ {\mathcal R
}^f(\pi_1(X),\, K)\,=\, \{\rho\, \in\, \text{Hom}(\pi_1(X),\, K)\, \mid\,
A\circ\rho \ \text{ factors through }~ f_*\}\, , $$ where $A: G \rightarrow
\text{GL}(\text{Lie}(G))$ is the adjoint action. We prove that the geometric
invariant theoretic quotient ${\mathcal R }^f(\pi_1(X, x_0), G)/\!\!/G$ admits
a deformation retraction to ${\mathcal R }^f(\pi_1(X, x_0),\, K)/K$. We also
show that the space of conjugacy classes of $n$ almost commuting elements in
$G$ admits a deformation retraction to the space of conjugacy classes of $n$
almost commuting elements in $K$.
