title: Return top level key based on presence of key at subobject
body: <p>I have a YAML file like this</p>
  <pre class="lang-yaml prettyprint-override"><code>---
  apps_membership:
    children:
      apps_prometheus:
        children:                                                                                                       
          group_1:
          group_2:
      apps_logstash:
        children:
          group_3:
          group_4:
      apps_alertmanager:
        children:
          group_1:
          group_2:
  </code></pre>
  <p>I try to get the groups when i look for a vm, for example is I look for <strong>group_1</strong> I want to get</p>
  <pre><code>apps_prometheus
  apps_alertmanager
  </code></pre>
  <p>I'm trying with a combination of <a href="https://github.com/kislyuk/yq" rel="nofollow noreferrer">kislyuk/yq</a> and jq with the map / key / contains</p>
  <p>----- Test with paths command</p>
  <p>If i use the command
  <code>yq -r '.apps_membership.children | paths'</code>
  I get this result:</p>
  <pre><code>[
    &quot;apps_prometheus&quot;
  ]
  [
    &quot;apps_prometheus&quot;,
    &quot;children&quot;
  ]
  [
    &quot;apps_logstash&quot;
  ]
  [
    &quot;apps_logstash&quot;,
    &quot;children&quot;
  ]
  [
    &quot;apps_alertmanager&quot;
  ]
  [
    &quot;apps_alertmanager&quot;,
    &quot;children&quot;
  ]
  </code></pre>
  <p>If i change the yaml with</p>
  <pre><code>    apps_alertmanager:
        children:
          group_1: &quot;&quot;
          group_2: &quot;&quot;
  </code></pre>
  <p>I get the desired output:</p>
  <pre><code>[
    &quot;apps_alertmanager&quot;
  ]
  [
    &quot;apps_alertmanager&quot;,
    &quot;children&quot;
  ]
  [
    &quot;apps_alertmanager&quot;,
    &quot;children&quot;,
    &quot;group_1&quot;
  ]
  [
    &quot;apps_alertmanager&quot;,
    &quot;children&quot;,
    &quot;group_2&quot;
  ]
  </code></pre>
  <p>How can i use the command paths to also get null values ?</p>