Implement 'union' and 'connected'