title: Update an deeply nested array in a freezed class in flutter
body: <p>I have a <a href="https://pub.dev/packages/freezed" rel="noreferrer">freezed</a> class in flutter as follows:</p>
  
  <pre><code>@freezed
  abstract class Data with _$Data {
    const factory Data({
      String id,
      String name,
      String parentId,//null if it is the root element
      @Default([]) List&lt;Data&gt; children,
    }) = _Data;
  }
  </code></pre>
  
  <p>The class contains a property called <code>children</code> which is a list of the same class i.e <code>Data</code>. </p>
  
  <p>The max nesting that is currently allowed 20 levels deep. 
  The problem I am facing is how to update a particular deeply nested <code>children</code> list by adding or removing items to it. Also this updating should be done keeping immutability and return a new updated <code>Data</code> class.</p>
  
  <p>I tried using <code>copyWith()</code> method on the freezed class but could not figure out the same when there is deeply nested as in my scenario.</p>