def _collect_ancestors(self, ancestors, types, inheritance_key_id, depth):
    """Augment the set 'ancestors' with superclasses of elements of types."""
    if depth > FLAGS.max_closure_depth:
      return
    new_types = set()
    for t in types:
      for key, val in t:
        if key.id == inheritance_key_id:
          if val not in ancestors:
            new_types.add(val)
            ancestors.add(val)
    if new_types:
      self._collect_ancestors(
          ancestors, new_types, inheritance_key_id, depth + 1)
Augment the set 'ancestors' with superclasses of elements of types.
language/templama/sling2facts.py