title: How can i find parent from nested object ? (Javascript)
body: <p>I have a nested object. I need a function. I need use it for find &quot;parent key&quot; Which function should i use for it ? My data :</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>[{
      "Name": "Main Menu",
      "Key": "1",
      "Children": [{
        "Name": "Sub Menu 1",
        "Key": "10",
        "Children": [{
          "Name": "Very Sub Menu",
          "Key": "20",
          "Children": []
        }]
      }]
    },
    {
      "Name": "Main Menu 2",
      "Key": "2",
      "Children": [{
        "Name": "Sub Menu 2",
        "Key": "11",
        "Children": [{
          "Name": "Very Sub Menu 2",
          "Key": "21",
          "Children": [{
            "Name": "Extra Small Menu",
            "Key": "30",
            "Children": []
          }]
        }]
      }]
    }
  ]</code></pre>
  </div>
  </div>
  </p>
  <p>For example when I send my array and key (For example &quot;10&quot;(Sub Menu 1) for that example) I need take 1 as a result (Main Menu Key.)</p>
  <p>Example 2 :
  If I give 30 as a key ; I need take 21 as a result. How can I do it ? Thanks for replies!</p>
  <p>I tried like :</p>
  <pre><code>var res = myData.filter(function f(o) {
        if (o.key === dragKey) return true;
  
        if (o.children) {
          return (o.children = o.children.filter(f)).length;
        }
      });
      console.log(res); // Its giving main whole data main level to child level. I need just 1 upper level data.
  </code></pre>