detectFoldRun function
The run starting at start when at least threshold consecutive siblings
share a signature; null otherwise.
Implementation
FoldRun? detectFoldRun(
List<SemanticNode> children,
int start, {
int threshold = 4,
}) {
if (start >= children.length) return null;
final sig = structuralSignature(children[start]);
var end = start + 1;
while (end < children.length && structuralSignature(children[end]) == sig) {
end++;
}
final length = end - start;
if (length < threshold) return null;
return FoldRun(start: start, length: length, signature: sig);
}