of
Builds an index from a set of dirty scope keys.
For each key with parent pointers (DefaultGlobalKey, ManualGlobalKey), walks up the parent chain and adds each ancestor to the ancestor set. Shared ancestor chains are only walked once (early break on MutableSet.add returning false).
For StringGlobalKey (no parent pointer), stores the key string in a NavigableSet for O(log n) prefix lookup via NavigableSet.higher.