	public <A> A requireAncestorTag(Class<A> tagClass) {
		TagStack ts = getTagStack();
		if (ts.size()>1) {
			for (int i=ts.size()-2;i>=0;--i) {
				PolygraphTag tag=ts.get(i);
				if (!tagClass.isInstance(tag)) {
					@SuppressWarnings("unchecked")
					A tag2 = (A)tag;
					return tag2;
				}
			}
		}
		throw new PolygraphTemplateException(String.format("Ancestor tag of type %s expected but not found.",tagClass.getName()));
	}

	public <A> A requireAncestorTag(Class<A> tagClass) {
		TagStack ts = getTagStack();
		if (ts.size()>1) {
			for (int i=ts.size()-2;i>=0;--i) {
				PolygraphTag tag=ts.get(i);
				if (tagClass.isInstance(tag)) {
					@SuppressWarnings("unchecked")
					A tag2 = (A)tag;
					return tag2;
				}
			}
		}
		throw new PolygraphTemplateException(String.format("Ancestor tag of type %s expected but not found.",tagClass.getName()));
	}
