title: Kotlin - Get all children recursively
body: <p>I'm new in Kotlin and trying to find best way to get all children in object.</p>
  <p>I have this data class</p>
  <pre><code>data class BigObj(val id: Int, val text: String, val parentId: Int?, val children: ArrayList&lt;BigObj&gt;)
  </code></pre>
  <p>What I need is - get all possible objects from BigObj.children. Every children can have another list of children and I need them all. In C# I can do this one:</p>
  <pre><code> foreach (var parent in source)
          {
              yield return parent;
  
              var children = selector(parent);
              foreach (var child in SelectRecursive(children, selector))
                  yield return child;
          }
  </code></pre>
  <p>Does Kotlin has something similar?</p>