Oh, if only life were so easy. :^)
Basically, the algorithm recursively processes this data structure, and deeper levels of the recursion rely on earlier levels having removed branches of the structure. This pruning effectively stops previously processed and rejected branches of the data being reprocessed at any given level.
However, as the recursion unwinds (having so far failed to resolve the solution), I need to restore the pruned branches in order that they may be considered when walking other branches taken higher (shallower) in the recursion process. The structure contains many cross-references at the leaf nodes. It is these that get pruned as the process progresses at the deeper levels, but that must be restored as the recursion unwinds.
The routine only selectively clones subtrees at any given level and passes these in when it recurses, so it is, in effect, tracking the changes and unwinding them. but given that the nature and depth of the structure is variable between runs, coming up with a generalised alternative tracking mechanism is more complex (and costly) than cloning the subtrees to lexicals as I go.
Examine what is said, not who speaks.
The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.
|