Unfortunately you can't gs.log when you are calling the code from a filter. I'd recommend temporarily adding a call to this object's function from within an on-demand Scheduled Job that you can trigger by hand and observe gs.log results. Then you could add gs.log statements to display the contents of the heirarchy array.