#Read in Tree use Bio::TreeIO; my $treeio = Bio::TreeIO->new(-format => 'newick',-file => $filename); my $tree = $treeio->next_tree; #You can find the species of interest ‘x' foreach my $id(@lines){ my $node = $tree->find_node(-id => $id); #Find internal node that is its immediate ancestor my $ancestral_node = $node->ancestor(); #Find all descendants from ancestor (which will include ‘x’) for my $child ( $ancestral_node->get_all_Descendents ) { print $child->id, "\n"; } }