Custom Java Rule to iterate over ASTs and log them to find out every path

Hello, everyone.
I’m using SonarQube and I’m currentlt trying to develop a new custom Java rule that can iterate over every node in an AST, in order to log every AST and then find out every possible path in a specific program. Does anyone have any suggestions or know of an already made template that might help?
Thanks for your attention!