Union Find Data Structure implementation