}
private Template cloneChildren(Template template, String aSelector, Element cloneNode)
{
cloneNode.removeAttribute("data-debug-id");
Template clonedTemplate= HTMLTemplateFactory.createTemplate(template.getName());
clonedTemplate.setFiringEvents(false);
clonedTemplate.setContent(new ContentImpl<Element>(cloneNode));
for (Template child : template.getChildrenMap().values())
{
String childName= child.getName();
String selector= aSelector + " " + createSelector(childName);
Element clonedElement= ServiceLocator.getInstance().getDomHandler().getElementBySelector(selector);
Template clonedChild= cloneChildren(child, selector, clonedElement);
clonedTemplate.addChild(clonedChild);
}
clonedTemplate.setFiringEvents(true);