Improve performance of `brew leaves` command

I thought the `brew leaves` command was pretty slow, so I optimized it.

The current version will resolve a dependency graph of all formulae, where my change will only consider the installed formulae. On my machine, this yields a great performance improvement:

    % time brew leaves
    [...]
    brew leaves  1.43s user 0.26s system 96% cpu 1.755 total

    % time brew leaves
    [...]
    brew leaves  0.13s user 0.05s system 96% cpu 0.189 total

I have both known and "unknown" stuff installed, and the output before my change is exactly the same as the output after my change.