title: Search in tree structure JSON data
body: <p>I am building dynamic menu in a tree structure with the search option.</p>
  
  <p>JSON Data looks like below:</p>
  
  <pre><code>directories = [
              {
                  name: 'parent1',
                  child: [{
                      name: 'child1',
                      child: [{
                          name: 'child2',
                          child: []
                      }]
                  },
                  {
                      name: 'child2',
                      child: []
                  }]
              },
              {
                  name: 'parent2',
                  child: [{
                      name: 'child1',
                      child: []
                  }]
              },
              {
                  name: 'parent2',
                  child: [{
                      name: 'child1',
                      child: []
                  },
                  {
                      name: 'child2',
                      child: []
                  }]
              }
          ];
      }
  </code></pre>
  
  <p>Below code to search items in parent node level:</p>
  
  <pre><code>searchFilter(search: string) {
          console.log(search);
          this.filteredArray = this.directories.filter(item =&gt; {
              if (item.name.toString().toLowerCase().startsWith(search.toLowerCase())) {
                  return true;
              }
              return false;
          }
          );
          console.log(this.filteredArray);
      }
  </code></pre>
  
  <p>I am calling above code on keyup event and it returns the search result on the parent node level.</p>
  
  <p>Now I want to do search till the nth child. Any help?</p>