New in version 2.0.
Get n th leaf in expr:
abjad> staff = Staff(Measure((2, 8), notetools.make_repeated_notes(2)) * 3)
abjad> pitchtools.set_ascending_named_diatonic_pitches_on_nontied_pitched_components_in_expr(staff)
abjad> f(staff)
\new Staff {
{
\time 2/8
c'8
d'8
}
{
\time 2/8
e'8
f'8
}
{
\time 2/8
g'8
a'8
}
}
abjad> for n in range(6):
... leaftools.get_nth_leaf_in_expr(staff, n)
...
Note("c'8")
Note("d'8")
Note("e'8")
Note("f'8")
Note("g'8")
Note("a'8")
Read backwards for negative values of n.
abjad> leaftools.get_nth_leaf_in_expr(staff, -1)
Note("a'8")
Note
Because this function returns as soon as it finds instance n of klasses, it is more efficient to call leaftools.get_nth_leaf_in_expr(expr, 0) than expr.leaves[0]. It is likewise more efficient to call leaftools.get_nth_leaf_in_expr(expr, -1) than expr.leaves[-1].
Return leaf of none.