commonSubtree<T> static method

State<T> commonSubtree<T>(
  1. Iterable<State<T>> nodes
)

The lowest node in the tree that encompasses all nodes.

Implementation

static State<T> commonSubtree<T>(Iterable<State<T>> nodes) => (nodes
    .map((s) => {s, ...s.ancestors()})
    .reduce((a, b) => a.intersection(b))
    .reduce((a, b) => a.order > b.order ? a : b));