How to get the content moderation entity related to node entity in drupal 8.2.x? from a content moderation entity, i know how to get the associated node:

 if ($entity-&gt;getEntityTypeId() == 'content_moderation_state' ) {
     $article_id=$entity-&gt;get('content_entity_id')-&gt;getString();
     $article = \Drupal\node\Entity\Node::load($article_id);
 }


What i need to do is the reverse.
Being able from hook_form_alter, to get the content moderation entity related to the node:

 function hook_form_alter(&amp;$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id){
  if ($form_id='node_article_edit_form')
  {
    $node=$form_state-&gt;getFormObject()-&gt;getEntity();
    //$node-&gt;get_content_moderation_entity??

}


}
i did it with entityQuery

function hook_form_alter(&amp;$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id){
 if ($form_id='node_article_edit_form')
  {      
    $article=$form_state-&gt;getFormObject()-&gt;getEntity();
    //get the associated content moderation entity
    $id = Drupal::entityQuery('content_moderation_state')
       -&gt;condition('content_entity_id', $article-&gt;id())
        -&gt;execute();

    $stateEntities = Drupal::entityManager()
        -&gt;getStorage('content_moderation_state')
        -&gt;loadMultiple($id);
    $stateEntity=array_values($stateEntities)[0];
    $moderation_state = $stateEntity-&gt;get('moderation_state')-&gt;getString();
   }
 }