in reply to Creating dynamic parent/child relationships

This definitely smells like an "XY Problem" that has probably already been solved several good metaphors have already been suggested here. And the key decision factor is: "sometimes, but not always." Once the scenario has been more carefully defined, an existing stock solution should readily suggest itself, and from this an appropriate implementation in Perl.