I'm all for having this merged, in fact, I had done something similar using a dictionary, but this is simpler, although performance-wise, it's still O(n^2) for the whole installation, I don't think it's a big deal, since it's installation after all. Have you tried this with a large number of bundles?

I think, however, and for the sake of sanity, that this would be a great opportunity to replace some of those one letter variable names with other more meaningful ones. That's my suggestion here.