my %threadhash; sub build_best_nodes_list my @nodes = get_list of relevant nodes_sorted_by_xp_descending(); my @found; foreach my $node ( @nodes ) { last if @found > 10; unless ( defined $threadhash{$node->{op}->{title}} ) { push @found, $node->{op}; $threadhash{$node->{op}->{title}} = 0 } $threadhash{$node->{op}->{title}}++; return @nodes; }