public static AWComponent componentWithTemplateNamed (String templateName,
AWComponent component)
{
AWComponent context = component;
for (; context != null; context = context.parent()) {
AWElement contentElement = context.componentReference().contentElement();
if (contentElement instanceof AWTemplate) {
AWTemplate template = (AWTemplate)contentElement;
if (template.indexOfNamedSubtemplate(templateName, component) != -1) {
return context;