def _transitive_parenthood(key,
                           term_dict):
  """Finds all parents, transitively, of `key` in `term_dict`.

  Does not include itself in the set of parents, regardless of the type of
  relation. This is left to the caller to decide.

  Args:
    key: Go Term, e.g. GO:0000001
    term_dict: Go term to set of parent go terms.

  Returns:
    Set of transitive parent go terms of `key`.
  """
  running_total = set()
  to_examine = set(term_dict[key])  # Make a copy so we can pop from it.

  while len(to_examine) > 0:  # pylint: disable=g-explicit-length-test
    cur_element = to_examine.pop()
    running_total.add(cur_element)

    for potential in term_dict[cur_element]:
      if potential not in running_total:
        to_examine.add(potential)

  return running_total