sub hash_nodes { my $tree=shift; my %h=(); my $sub; $sub = sub ($) { my $node=shift; my $value=$node->getNodeValue(); push(@{$h{$value}},$node); }; $tree->traverse($sub); return %h; }