docs: def get_session_conf_dir(self, cleanup=False):
          """
          Tries to find the session configuration directory by looking in ~/.dnanexus_config/sessions/<PID>,
          where <PID> is pid of the parent of this process, then its parent, and so on.
          If none of those exist, the path for the immediate parent is given, even if it doesn't exist.
  
          If *cleanup* is True, looks up and deletes all session configuration directories that belong to nonexistent
          processes.
          """
          sessions_dir = os.path.join(self._user_conf_dir, "sessions")
          try:
              from psutil import Process, pid_exists
  
              if cleanup:
                  try:
                      session_dirs = os.listdir(sessions_dir)
                  except OSError as e:
                      # Silently skip cleanup and continue if we are unable to
                      # enumerate the session directories for any reason
                      # (including, most commonly, because the sessions dir
                      # doesn't exist)
                      session_dirs = []
                  for session_dir in session_dirs:
                      try:
                          session_pid = int(session_dir)
                      except ValueError:
                          # If dir name doesn't look like an int, leave it
                          # alone
                          continue
                      if not pid_exists(session_pid):
                          rmtree(os.path.join(sessions_dir, session_dir), ignore_errors=True)
  
              parent_process = Process(os.getpid()).parent()
              default_session_dir = os.path.join(sessions_dir, str(parent_process.pid))
              while parent_process is not None and parent_process.pid != 0:
                  session_dir = os.path.join(sessions_dir, str(parent_process.pid))
                  if os.path.exists(session_dir):
                      return session_dir
                  parent_process = parent_process.parent()
              return default_session_dir
          except (ImportError, IOError, AttributeError) as e:
              # We don't bundle psutil with Windows, so failure to import
              # psutil would be expected.
              if platform.system() != 'Windows':
                  warn(fill("Error while retrieving session configuration: " + format_exception(e)))
          except Exception as e:
              warn(fill("Unexpected error while retrieving session configuration: " + format_exception(e)))
          return self._get_ppid_session_conf_dir(sessions_dir)