If you search a specific identifier(reference) / variable, this is the way to do it.
Yeah, this is very primitive. Adding some helper methods walking scope chains to escope library sounds nice.