ideally we should properly inspect for recursion, i.e. loops in a graph
among tags (first build adjacency matrix, i.e. which tag uses which
tag), and then use one of those
http://en.wikipedia.org/wiki/Strongly_connected_components
to detect if there is any loop (strongly connected component)

-- 
Yaroslav O. Halchenko, Ph.D.
http://neuro.debian.net http://www.pymvpa.org http://www.fail2ban.org
Senior Research Associate,     Psychological and Brain Sciences Dept.
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
Phone: +1 (603) 646-9834                       Fax: +1 (603) 646-1419
WWW:   http://www.linkedin.com/in/yarik