For $x, a$ sets, let the *Mostowski rank of $x$ at set $a$*, $MR_a(x)$, be the rank of $x$ in the Mostowski collapse *applied to $R\cap a^2$.* Let the *Mostowski spectrum* of a set $x$, $MS(x)$, be the set of possible values of the Mostwoski rank of $x$, as $a$ varies over all sets. On the face of it, $MS(x)$ is a *class*, rather than a *set*. However, by induction on $H(x)$, $MS(x)$ is bounded; specifically, for each ordinal $\alpha$ there is some ordinal $b(\alpha)$ such that $H(x)\le \alpha$ implies $MS(x)\subseteq \beta$. For example, if $\alpha=0$, then $b(\alpha)=1$, since every $x$ with $H(x)=0$ can only ever be collapsed to $0$. (Indeed, regardless of $R$ we'll always have $b(\alpha)\le\alpha+1$, but we don't need that here.)

In fact, $MS(x)$ has a maximum! Why? Well, for every $\alpha\in MS(x)$, let $S_\alpha$ be a set containing $x$, such that $MR_{S_\alpha}(x)=\alpha$. Now consider the set $T=\bigcup_{\alpha\in MS(\alpha)} S_\alpha$. Mostowski rank is monotonic: $a\subseteq b$ implies $MR_a(x)\le MR_b(x)$. So $MR_T(x)\ge \alpha$ for every $\alpha\in MS(\alpha)$. But also $MR_T(x)\in MS(x)$, by definition. So it is the maximum of this set.

Now consider the map $\mu(x)=\max(MS(x))$.