Add cache to TemplatesFromTree