I am in need of searching for a specific value within an object graph. Once this value is found, I want to set the 'expanded' property to true on that particular object, as well as on all containing objects up the object graph.
For example, given the following data:
`regions: [
{ id: 1, name: 'Canada Mock', code: 'CA', bulk: '', expanded: false, subRegions: [] },
{ id: 2, name: 'Mexico', code: 'MX', bulk: '', expanded: false, subRegions: [] },
{
id: 2, name: 'United States region', code: 'US', bulk: '', expanded: false, subRegions: [
{
id: 1, name: 'US sub region', countries: [
{id: 1, name: 'Saint Vincent and the Grenadines', code:'SV', states:[]},
{id: 2, name: 'Trinidad and Tobago', code:'TR', states:[]},
{
id: 3, name: 'United States', code:'US', states: [
{ id: 1, name: 'Alabama', code: 'AL', expanded: false, cities: [] },
...
]
},
...
}
]
}
]
}
]`
If I were to search for 'LGA', the path leading to it would be expanded as follows: 'United States region'->'US sub region'->'United States'->'New York'->'New York City'