Rewrite unionfind.
.
.