getDescendantsOfKey method
Retrieves all descendant item keys for a given item key in tree hierarchy.
Implementation
Set<K> getDescendantsOfKey(K key) {
final descendants = <K>{};
void collect(K parentKey) {
final item = _itemsMap[parentKey];
if (item != null && item.hasChildren) {
for (final childKey in item.childrenKeys!) {
descendants.add(childKey);
collect(childKey);
}
}
}
collect(key);
return descendants;
}