title: Recursive function and Map for accessing Elements in nested Array
body: <p><strong>Situation</strong></p>
  
  <ul>
  <li>I have an nested Array and I have a ID to search for. Like "A_02_02_01_03"</li>
  <li>Every Element in an array has a element called "children", that is a
  array</li>
  <li>My method gets pretty long when I'm searching in the 4th Layer.</li>
  </ul>
  
  <p><strong>Example Array</strong></p>
  
  <pre><code>var tree= [
    {
      "name": "i2",
      "children": [
        {
          "name": "d1",
          "children": [],
          "id": "DW_02_01",
          "beschreibung": "",
          "table": []
        },
        {
          "name": "d2",
          "children": [
            {
              "name": "e1",
              "children": [
                {
                  "name": "a1",
                  "children": [],
                  "id": "A_02_02_01_01",
                  "beschreibung": "",
                  "table": []
                },
                {
                  "name": "a2",
                  "children": [],
                  "id": "A_02_02_01_02",
                  "beschreibung": "",
                  "table": []
                },
                {
                  "name": "a3",
                  "children": [],
                  "id": "A_02_02_01_03",
                  "beschreibung": "",
                  "table": []
                }`enter code here`
              ],
              "id": "E_02_02_01",
              "beschreibung": "",
              "table": []
            },
            {
              "name": "e2",
              "children": [],
              "id": "E_02_02_02",
              "beschreibung": "",
              "table": []
            }
          ],
          "id": "DW_02_02",
          "beschreibung": "",
          "table": []
        },
        {
          "name": "d3",
          "children": [],
          "id": "DW_02_03",
          "beschreibung": "",
          "table": []
        }
      ],
      "id": "IW_02",
      "beschreibung": "",
      "table": []
    },
    {
      "name": "i3",
      "children": [],
      "id": "IW_03",
      "beschreibung": "",
      "table": []
    }
  ]
  </code></pre>
  
  <p><strong>Constructing IDs</strong></p>
  
  <pre><code>var daIW = "IW_02";
  var daDW = "DW_02_02;
  var daE = "E_02_02_01;
  var daA = "A_02_02_01_03";
  </code></pre>
  
  <p><strong>Getting all my indices</strong></p>
  
  <pre><code>var iw_index = tree.findIndex(element =&gt; element.id == daIW);
  var dw_index = tree[iw_index]["children"].findIndex(element =&gt; element.id == daDW);
  var e_index = tree[iw_index]["children"][dw_index]["children"].findIndex(element =&gt; element.id == daE);
  var a_index = tree[iw_index]["children"][dw_index]["children"][e_index]["children"].findIndex(element =&gt; element.id == daA);
  </code></pre>
  
  <p><strong>Accessing my Element</strong></p>
  
  <pre><code>var elementName = tree[iw_index]["children"][dw_index]["children"][e_index]["children"][a_index].name;
  </code></pre>
  
  <p><strong>Question</strong></p>
  
  <p>Is there a shorter way for accessing the deepest Element "A_02_02_01_03" then searching for every index?</p>