def _FindContexts(start_token):
  """Depth first search of all contexts referenced by a token stream.

  Includes contexts' parents, which might not be directly referenced
  by any token in the stream.

  Args:
    start_token: First token in the token stream.

  Yields:
    All contexts referenced by this token stream.
  """

  seen_contexts = set()

  # For each token, yield the context if we haven't seen it before.
  for token in start_token:

    token_context = token.metadata.context
    contexts = [token_context]

    # Also grab all the context's ancestors.
    parent = token_context.parent
    while parent:
      contexts.append(parent)
      parent = parent.parent

    # Yield each of these contexts if we've not seen them.
    for context in contexts:
      if seen_contexts not in context:
        yield context

      seen_contexts.add(context)
dataset/ETHPy150Open google/closure-linter/closure_linter/scopeutil_test.py/_FindContexts/swapped operands of `not in`