code: def get_default_terminal(environ=None, fallback=_UNSPECIFIED):
      if environ is None:
          environ = os.environ
      if "PIAS_OPT_TERMINAL" in environ:
          return environ["PIAS_OPT_TERMINAL"]
      terminals = []
      colorterm = environ.get("COLORTERM")
      for filename in (colorterm, "gnome-terminal", "konsole", "xterm"):
          if filename is not None:
              filepath = find_executable(filename, environ)
              if filepath is not None:
                  terminals.append(filepath)
      for ancestor in get_ancestor_processes():
          if ancestor in terminals:
              return ancestor
      for term in terminals:
          return term
      if fallback is not _UNSPECIFIED:
          return fallback
      raise ValueError("Could not find a terminal")