Go implementation of union-find data structure