This code performs a linear search through the AST. I am not sure why is this needed in the first place. If such a search is absolutely needed, the best would be to use [Locator](https://github.com/scala/scala/blob/master/src/reflect/scala/reflect/internal/Positions.scala#L240), it should have much better performance.