Refactoring of addTrailsToTrailheads to loopify.