Refactor/optimize tree-sitter utilities for finding nodes enclosing ranges (#37943)

#35053 split out these utility functions. I found the names / doc
comments a bit confusing so this improves that. Before that PR there was
also a mild inefficiency - it would walk the cursor all the way down to
a leaf and then back up to an ancestor.

Release Notes:

- N/A
11b7913956Michael Sloan committed on 9/11/2025, 9:42:09 PM· committed by GitHubparentff2eebf
1 file changedLine totals unavailable