[jit] Factor findAllNodes into one place. (#65965)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/65965
ghstack-source-id: 141504185
Test Plan: no behavior change
Reviewed By: qihqi, ejguan
Differential Revision: D31326152
fbshipit-source-id: 2e0261a96853bfb67a96dd68972c905b6b26d562