Kotlin - Get all children recursively
I'm new in Kotlin and trying to find best way to get all children in object.
I have this data class
data class BigObj(val id: Int, val text: String, val parentId: Int?, val children: ArrayList)
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:
foreach (var parent in source)
{
yield return parent;
var children = selector(parent);
foreach...