New recursive hideTemplates() function