Setting $k=Gh$, see if you can write $\mathrm{tr}_gk$ in terms of $\mathrm{tr}_gh$ (and thus vice versa). You should find a relatively clean expression, and from there it's just simple algebra: suppose $\mathrm{tr}_gh = f(\mathrm{tr}_gk)$ for some $f$. Then $k_{ij}=h_{ij}-\frac12f(\mathrm{tr}_gk)g_{ij}$, so $h_{ij}=k_{ij}+\frac12f(\mathrm{tr}_gk)g_{ij}$.