lib: add `union_find`, a union–find algorithm with a disjoint-set data structure