Implement template circularity detection