A fairly simple change to my script fixed the problem.
In each call to &Recurse
I additionally pass a
list. This list contains all of the
'parent' nodes in the call tree. So when the function runs,
it checks to see if the node is present in @stack
then I know there is circular reference.
So, the inital invocation of &Recurse becomes:
&Recurse($_,()), and subsequent calls (the
truly recursive ones) turn into: &Recurse($node,@stack,$node).
This works, although tilly has a much more compact solution. :-)