debugTree function