Is it possible to collapse these two methods, using a keyword argument of something like <samp>use_efficient_method</samp> and then putting an e.g. <code>if use_efficient_method:</code> block in the <samp>for name in hierarchy:</samp> loop?