- my $self = shift;
- _add_message($self, $_) foreach @{$self->{messages}};
- my $id_table = delete $self->{id_table};
- $self->{rootset} = [ grep { !delete $_->{parent} } values %$id_table ];
+ my ($messages, $ordersub, $ibx) = @_;
+ my $id_table = {};
+ _add_message($id_table, $_) foreach @$messages;
+ my $rootset = [ grep {
+ !delete($_->{parent}) && $_->visible($ibx)
+ } values %$id_table ];
+ $id_table = undef;
+ $rootset = $ordersub->($rootset);
+ $_->order_children($ordersub, $ibx) for @$rootset;
+ $rootset;