title: MongoDB, how to query nested Document/object/field in tree like structure
body: <p>I have following document structure stored in Mongodb. Please note &quot;next&quot; is an array.</p>
  <pre><code>{
    &quot;id&quot;: 1,
    &quot;pricing&quot;: [
      {
        &quot;name&quot;: &quot;name1&quot;,
        &quot;value&quot;: &quot;v1&quot;,
        &quot;next&quot;: [
          {
            &quot;name&quot;: &quot;name2&quot;,
            &quot;value&quot;: &quot;v2&quot;,
            &quot;next&quot;: [
              {
                &quot;name&quot;: &quot;name3&quot;,
                &quot;value&quot;: &quot;v3&quot;,
                &quot;next&quot;: [
                ]
              }
            ]
          }
        ]
      }
    ]
  }
  </code></pre>
  <p>How can I find the eg. name=name3 or any arbitrary value from it? Not knowing if it exists or not.</p>