(#22142) Substantial speed increase in lookups

Previously, hiera would look up the 'datadir' from config
inside the loop where it looks inside datafiles. This caused
substantial slowdowns on sites with deep hierarchies.

This commit moves the datadir lookup to be outside the
the datasource-search loop and caused substantial speedups.
(Timings are in the original ticket).

This patch was written by Sean Millichamp; I just rebased it
onto the current state of Hiera and submitted it on his behalf.