in reply to Q on $var = \$var;

Yes. $var = undef breaks the loop and allow it to be freed.

A trick is to have an object that manages (contains, provides access to) the nodes, but isn't referenced by any of the nodes. Since there's only one reference to the manager, its DESTROY will be called when it goes out of scope, and it can break any references in the list.