short version: a jsonpath implementation. for js/ts, jsonpath-plus is a good bet.
long version: a function to recurse over the tree (for when adding a jsonpath library isn't an option)
this could be complemented with some optional dependencies that enable helper functions