for my $name ( $tree->ancestor->son->sibbling ) { if ( $name ... ) { # ... } # ... }