fold<T> method
Depth-first fold: Applies combine to itself and all descendant nodes.
Example usage:
final nodeCount = doc.fold<int>(0, (acc, _) => acc + 1);
Implementation
T fold<T>(T initial, T Function(T acc, LatexNode node) combine) {
var acc = combine(initial, this);
for (final child in children()) {
acc = child.fold(acc, combine);
}
return acc;
}