def METHOD_NAME(key):
    """Restore a session specified by key, previously saved by the session manager."""
    settings = sessionSettings(key)
    ## restore current named session name
    session_name = settings.value('session_name', "", str)
    if session_name:
        import sessions
        sessions.setCurrentSession(session_name)
    ## restore documents
    numdocuments = settings.value('numdocuments', 0, int)
    doc = None
    for index in range(numdocuments):
        settings.beginGroup(f"document{index}")
        url = settings.value("url", QUrl(), QUrl)
        if url.isEmpty():
            import document
            doc = document.EditorDocument()
        else:
            try:
                doc = app.openUrl(url)
            except OSError:
                pass
        settings.endGroup()
    # open at least one
    if doc is None:
        doc = app.openUrl(QUrl())
    ## restore windows
    numwindows = settings.value('numwindows', 0, int)
    if numwindows > 0:
        for index in range(numwindows):
            settings.beginGroup(f"mainwindow{index}")
            win = mainwindow.MainWindow()
            win.readSessionSettings(settings)
            win.show()
            app.qApp.processEvents()    # init (re)size dock tools
            u = settings.value("active_document", QUrl(), QUrl)
            # we don't use app.findDocument because it does not allow empty url
            for d in app.documents:
                if u == d.url():
                    win.setCurrentDocument(d)
                    break
            else:
                win.setCurrentDocument(app.documents[0])
            settings.endGroup()
    else:
        win = mainwindow.MainWindow()
        win.show()
        app.qApp.processEvents()    # init (re)size dock tools