UnionFind: cleanup

@7andrew7 rightly pointed out that having get call get_or_insert is
crazy, even though it now will not mutate the object. Fix this by
having get_or_insert first insert if needed, then call get.