findNodeSuchThat static method

Tree? findNodeSuchThat(
  1. Tree? t,
  2. bool pred(
    1. Tree?
    )
)

Return first node satisfying the pred

@since 4.5.1

Implementation

static Tree? findNodeSuchThat(Tree? t, bool Function(Tree?) pred) {
  if (pred(t)) return t;

  if (t == null) return null;

  final n = t.childCount;
  for (var i = 0; i < n; i++) {
    final u = findNodeSuchThat(t.getChild(i), pred);
    if (u != null) return u;
  }
  return null;
}