def resolve(self, requirements, env=None, installer=None):
requirements = list(requirements)[::-<NUM_LIT:1>]  <EOL>processed = {}  <EOL>best = {}  <EOL>to_activate = []<EOL>while requirements:<EOL><INDENT>req = requirements.pop(<NUM_LIT:0>)   <EOL>if req in processed:<EOL><INDENT>continue<EOL><DEDENT>dist = best.get(req.key)<EOL>if dist is None:<EOL><INDENT>dist = self.by_key.get(req.key)<EOL>if dist is None:<EOL><INDENT>if env is None:<EOL><INDENT>env = Environment(self.entries)<EOL><DEDENT>dist = best[req.key] = env.best_match(req, self, installer)<EOL>if dist is None:<EOL><INDENT>raise DistributionNotFound(req)  <EOL><DEDENT><DEDENT>to_activate.append(dist)<EOL><DEDENT>if dist not in req:<EOL><INDENT>raise VersionConflict(dist,req) <EOL><DEDENT>requirements.extend(dist.requires(req.extras)[::-<NUM_LIT:1>])<EOL>processed[req] = True<EOL><DEDENT>return to_activate<EOL>
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``.