I think this should find the problem record for you.  It adds a LEVEL to your hierarchy, then looks for an individual ID record that exists at multiple levels.

;WITH ClassTree
           AS (SELECT ID, NAME, Parent_ID, 1 as 'Level'
               FROM   TableName
               WHERE  ID = 1
               UNION ALL
               SELECT T.ID, T.NAME, T.Parent_ID, Level + 1 as 'Level'
               FROM   TableName T WITH (NOLOCK)
                      JOIN ClassTree
                        ON Parent_ID = ClassTree.ID
)

SELECT *
FROM ClassTree c1
WHERE EXISTS (SELECT 1 FROM ClassTree c2
              WHERE c2.id = c1.id
              AND c2.Level &gt; c1.level)


CTE Running in Infinite Loop
I have a short description for each of my equations. I want to have them flushleft (similar to the equation numbers which are flushright). How can I do that?

Here is a MWE:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\text{this is my first equation: } z = x
\end{equation}
\begin{equation}
\text{this is my second equation: } z = x+y
\end{equation}
\end{document}


And my desired output is like this:

