sub path_to_root { my $self = shift; my $path = $self->get_branch_length; while ( $self ) { if ( $self = $self->get_parent ) { $path += $self->get_branch_length; } else { return $path; } } }