sub find { my $tree = shift; my $node_value=shift; my @childs=(); my $func; $func = sub ($) { my $child=shift(); push(@childs,$child) if($child->getNodeValue() eq $node_value); my @children=$child->getAllChildren(); $func->(shift(@children)) while(@children); }; $func->($tree); return @childs; }