title: Merge Sets of Sets that contain common elements in Scala
body: <p>I want to implement a function in Scala, that, given a Set of Sets of Ints will merge any containing Set that contains one or more common elements. </p>
  
  <p>So for example, given:</p>
  
  <pre><code>def mergeSets(sets: Set[Set[Int]]): Set[Set[Int]] = ???
  
  val sets = Set(Set(1,2), Set(2,3), Set(3,7), Set(8,10))  
  val mergedSets = mergeSets(sets)
  </code></pre>
  
  <p>mergedSets will contain Set(Set(1,2,3,7), Set(8,10))</p>
  
  <p>What would be a nice, efficient and functional if possible, way to do this in Scala?</p>