code: def _search_inasafe_layer(self):
          
          selected_nodes = self.iface.layerTreeView().selectedNodes()
          for selected_node in selected_nodes:
              tree_layers = [
                  child for child in selected_node.children() if (
                      isinstance(child, QgsLayerTreeLayer))]
              for tree_layer in tree_layers:
                  layer = tree_layer.layer()
                  keywords = self.keyword_io.read_keywords(layer)
                  if keywords.get('inasafe_fields'):
                      return layer
docs: Search for an inasafe layer in an active group.
  
          :returns: A valid layer.
          :rtype: QgsMapLayer
  
          .. versionadded:: 4.3