I am working on a search function for a parent child structure with locations (city,suburb,street).
I want to search for a street name and get the results but keeping the structure.

The array structure is like this:

```
const cities = [
  {
    name: 'city1', sublocations: [
      {
        name: 'suburb1', sublocations: [
          {name: 'street1'},
          {name: 'street2'},
          {name: 'street3'},
        ]
      }, {
        name: 'suburb2', sublocations: [
          {name: 'street1'},
          {name: 'street2'},
          {name: 'street3'},
        ]
      }
    ]
  }
];

```

When I search for *street1* for example I want to get this:

```
const cities = [
  {
    name: 'city1', sublocations: [
      {
        name: 'suburb1', sublocations: [
          {name: 'street1'},
        ]
      }, {
        name: 'suburb2', sublocations: [
          {name: 'street1'},
        ]
      }
    ]
  }
];

```

I tried it with the array.filter function but it overwrites the data and when I remove the search string the rest of the array doesn't come back.