I am so silly.
The method #enum_for
gives me all the power here. I can implement Charlie's syntax of
tree.breadth_first.find(13)
by adding the conventional line
return self.enum_for(__method__) unless block_given?
in each of my traversal methods. The tree.breadth_first
will return an Enumerator
which enumerates according to the breadth-first algorithm; any Enumerable
method called on that will use that enumeration internally.