First, I will traverse the sorted array of parent lines. This could be derived from the keys of a hash, or from an array.
When a parent has children, I'll need to process/aggregate each of those elements, and associate the result with the parent.
I'm leaning towards this structure:
$a->[n]->[0] = arrayref to split parent lines
$a->[n]->[1] = arrayref to arrayref of split children lines
Where do you want *them* to go today?