title: groovy/java check list intersections and combine elements
body: <p>I have a list:</p>
  
  <pre><code>def a = [[14, 17, 12, 5], [14, 17, 12, 8, 3], [5, 2], [9]]
  </code></pre>
  
  <p>I need to check intersections and if two lists intersect, combine them. </p>
  
  <p>The result should be as follows:</p>
  
  <pre><code>def b = [[14, 17, 12, 5, 8, 3, 2], [9]]
  </code></pre>
  
  <p>(i.e 14 is in first sublist, which is also in second sublist, and recursively so on...)
  How this task can be solved?</p>