How to diagnose the «Call to a member function setActive() on boolean in Magento/Backend/Model/View/Result/Page.php» failure?

The problem method is \Magento\Backend\Model\View\Result\Page::setActiveMenu():

Loot at the lines:

The «Call to a member function setActive() on boolean» means that the $this->layout->getBlock('menu') code returns false: the menu block is absent.

menu is a standard block, it definitely should present in the layout, and its absence usually means that the layout is broken.
In my practice, it always was caused by an invalid XML file.
Here is my latest case:

This layout is invalid, because the layout='checkout' attribute is not allowed here and breaks Magento 2 backend with the «Call to a member function setActive() on boolean» message.

The correct version is:

So how to detect the problem XML file?
You can detect it by a sequential disabling the installed third-party modules in the app/etc/config.php file.