title: How to do filter on nested array of object in more than two level
body: <p>I have a nested array of objects, I'm trying to filter the given array of objects using a property from the third level of its array property value. For example, from the below array I like to filter the entire array using the property <code>&quot;state&quot; = &quot;NY&quot;</code>.</p>
  <pre><code>organisation = [
     {
        &quot;dept_id&quot;:1,
        &quot;dept&quot;:{
           &quot;name&quot;:&quot;finance&quot;,
           &quot;employees&quot;:[
              {
                 &quot;emp_id&quot;:1,
                 &quot;name&quot;:&quot;John&quot;,
                 &quot;address&quot;:[
                    {
                       &quot;country&quot;:&quot;US&quot;,
                       &quot;state&quot;:&quot;NC&quot;
                    }
                 ]
              }
           ]
        }
     },
     {
        &quot;dept_id&quot;:2,
        &quot;dept&quot;:{
           &quot;name&quot;:&quot;marketing&quot;,
           &quot;employees&quot;:[
              {
                 &quot;emp_id&quot;:2,
                 &quot;name&quot;:&quot;David&quot;,
                 &quot;address&quot;:[
                    {
                       &quot;country&quot;:&quot;US&quot;,
                       &quot;state&quot;:&quot;NY&quot;
                    }
                 ]
              }
           ]
        }
     },
     {
        &quot;dept_id&quot;:3,
        &quot;dept&quot;:{
           &quot;name&quot;:&quot;sales&quot;,
           &quot;employees&quot;:[
              {
                 &quot;emp_id&quot;:3,
                 &quot;name&quot;:&quot;Robert&quot;,
                 &quot;address&quot;:[
                    {
                       &quot;country&quot;:&quot;US&quot;,
                       &quot;state&quot;:&quot;NC&quot;
                    }
                 ]
              }
           ]
        }
     }
  ]
  </code></pre>
  <p>As a result of using the filter <code>&quot;state&quot;:&quot;NY&quot;</code> my expected answer is</p>
  <pre><code>organisation = [
     {
        &quot;dept_id&quot;:2,
        &quot;dept&quot;:{
           &quot;name&quot;:&quot;marketing&quot;,
           &quot;employees&quot;:[
              {
                 &quot;emp_id&quot;:2,
                 &quot;name&quot;:&quot;David&quot;,
                 &quot;address&quot;:[
                    {
                       &quot;country&quot;:&quot;US&quot;,
                       &quot;state&quot;:&quot;NY&quot;
                    }
                 ]
              }
           ]
        }
     }
  ]
  </code></pre>
  <p>How can I use filter method using javascript to get this expected result.</p>