AST utility to collect scope info for variables