code: protected ElemTemplateElement getElemFromExpression(Expression expr)
    {
    	ExpressionNode parent = expr.exprGetParent();
    	while(null != parent)
    	{
    		if(parent instanceof ElemTemplateElement)
    			return (ElemTemplateElement)parent;
    		parent = parent.exprGetParent();
    	}
    	throw new RuntimeException(XSLMessages.createMessage(XSLTErrorResources.ER_ASSERT_NO_TEMPLATE_PARENT, null));
    	// "Programmer's error! expr has no ElemTemplateElement parent!");
    }
docs: From an XPath expression component, get the ElemTemplateElement
  owner.
  
  @param expr Should be static expression with proper parentage.
  @return Valid ElemTemplateElement, or throw a runtime exception
  if it is not found.