There is. Think about the layers on the left panel for a bit. If you had a folded layer for the instance and wanted to figure out if there’s a variant “Brand” somewhere in there, what would do?
Well… just as you would start at the top layer for the instance, expand it,
and look at the child layers, and...
1. for each layer ("let's call it L") you will ask:
2. is L the variant ? then
3. yey! "you are done!"
4.
5. but if not...
6. # you'll go inside that layer and check its inner layers, right?
7. # exactly like you did with L !
8. so you can send this layer all the way up to line 1
9. pretend it is now L an run the same steps on it!
That’s recursion 🙂 and you can do the same thing in code. Just instead of clicking to see which folders are inside an instance layer, you’ll look in node.children
ask: instance.children.some(child => child == Brand variant)
NOTE: That may be very slow if you have too many instances with many, many layers inside them to check. It would be much better if you could add a boolean property to the component that says if it should be update or not and check for that.
Hope that helped! If you have any questions, after you research “recursive algorithm to find nodes in trees”, feel free to ask! 😉
Thank you so much, will try to dig deep into it and let you know!