findCommonAncestor method
StateDefinition<State> ?
findCommonAncestor(
- Graph graph,
- StatePath fromAncestors,
- StatePath toAncestors
Walks up the tree looking for an ancestor that is common
to the fromAncestors
and toAncestors
paths.
If no common ancestor is found then null is returned;
Implementation
StateDefinition? findCommonAncestor(
Graph graph, StatePath fromAncestors, StatePath toAncestors) {
final toAncestorSet = toAncestors.path.toSet();
for (final ancestor in fromAncestors.path) {
if (toAncestorSet.contains(ancestor)) {
return ancestor;
}
}
return null;
}