// Note: This algorithm for finding the lead scopes relies on the fact that enclosing
// scopes are earlier than enclosed scopes in the list.
leaf_scopes = set()
for scope in known_scopes:
if scope:
outer_scope, _, _ = scope.rpartition(".")
if outer_scope in leaf_scopes:
leaf_scopes.discard(outer_scope)
leaf_scopes.add(scope)
for scope in leaf_scopes:
self._known_scoping_prefixes["{0}-".format(scope.replace(".", "-"))] = scope