docs: def _collapse_device(self, node, flat):
          """Collapse device hierarchy into a flat folder."""
          items = [item
                   for branch in node.branches
                   for item in self._collapse_device(branch, flat)
                   if item]
          show_all = not flat or self._quickmenu_actions == 'all'
          methods = node.methods if show_all else [
              method
              for method in node.methods
              if method.method in self._quickmenu_actions
          ]
          if flat:
              items.extend(methods)
          else:
              items.append(MenuSection(None, methods))
          return items