title: Get only significant data from nested lists
body: <p>Hi! I want to get only the significant information (complete flow) of a download link.</p>
  
  <p>I have my domain designed something like this:</p>
  
  <pre class="lang-js prettyprint-override"><code>Serie { hasMany[Season] }
  Season { hasMany[Episode] and belongsTo[Serie] }
  Episode { hasMany[DownloadInfo] and belongsTo[Season] }
  DownloadInfo { link nullable:true //among other data }
  </code></pre>
  
  <p>And I have in my DB approximately this number of records:</p>
  
  <pre class="lang-js prettyprint-override"><code>serie:4500
  season:500
  episode:6500
  download_info:10000
  </code></pre>
  
  <p>We can see that there are a lot of series without other information.</p>
  
  <p><strong>How can I get only those series>season>episode>downloadInfo data only where all of these are completed?</strong></p>
  
  <p>For example, having:</p>
  
  <pre class="lang-js prettyprint-override"><code>Serie "A"
    Season "sA1"
  Serie "B"
    Season "sB1"
      Episode "eB1"
        Link "b1.1"
        Link "b1.2"
      Episode "eB2"
      Episode "eB3"
        Link "b3.1"
  Serie "C"
    Season "sC1"
      Episode "eC1"
  Serie "D"
  Serie "E"
    Season "sE1"
      Episode "eE1"
        Link "e1.1"
    Season "sE2"
      Episode "eE2"
        Link "e2.1"
  </code></pre>
  
  <p>I want to get this:</p>
  
  <pre class="lang-js prettyprint-override"><code>def model = [series:[
    name:'B',
    seasons:[
      name:'sB1',
      episodes:[
        name:'eB1',
        links:['b1.1','b1.2']
      ],[
        name:'eB3',
        links:['b3.1']
      ]
    ]
  ],[
    name:'E'
    seasons:[
      name:'sE1',
      episodes:[
        name:'eE1',
        links:['e1.1']
      ]
    ],[
      name:'sE2'
      episodes:[
        name:'eE2',
        links:['e2.1']
      ]
    ]
  ]
  </code></pre>
  
  <p><strong>Discarding all Series, Seasons Episodes and DownloadInfo that has no link.</strong></p>
  
  <p>BTW, I need only the DownloadInfo where link property is not null.
  I started with:</p>
  
  <pre class="lang-js prettyprint-override"><code>DownloadInfo.where { link!= null }.list().each {
    // ...
  }
  </code></pre>
  
  <p>But I can't figure out an elegant way to do all the flow. Any clue?</p>
  
  <p>Thanks in advance!</p>
  
  <p><strong>Updated</strong></p>
  
  <p>It would be the Groovy's equivalent to the following SQL, grouped by name of each entity:</p>
  
  <pre class="lang-sql prettyprint-override"><code>select * from serie s
  inner join season ss on s.id = ss.serie_id
  inner join episode e on ss.id = e.season_id
  inner join download_info di on e.id = di.episode_id
  where di.link is not null
  </code></pre>