'List all distributions needed to (recursively) meet `requirements`
`requirements` must be a sequence of ``Requirement`` objects.  `env`,
if supplied, should be an ``Environment`` instance.  If
not supplied, it defaults to all distributions available within any
entry or distribution in the working set.  `installer`, if supplied,
will be invoked with each requirement that cannot be met by an
already-installed distribution; it should return a ``Distribution`` or
``None``.'

def resolve(self, requirements, env=None, installer=None):

    requirements = list(requirements)[::(-1)]
    processed = {}
    best = {}
    to_activate = []
    while requirements:
        req = requirements.pop(0)
        if (req in processed):
            continue
        dist = best.get(req.key)
        if (dist is None):
            dist = self.by_key.get(req.key)
            if (dist is None):
                if (env is None):
                    env = Environment(self.entries)
                dist = best[req.key] = env.best_match(req, self, installer)
                if (dist is None):
                    raise DistributionNotFound(req)
            to_activate.append(dist)
        if (dist not in req):
            raise VersionConflict(dist, req)
        requirements.extend(dist.requires(req.extras)[::(-1)])
        processed[req] = True
    return to_activate
