code: def transitive_subgraph_of_addresses_bfs(self,
                                             addresses,
                                             predicate=None,
                                             dep_predicate=None):
      
      walk = self._walk_factory(dep_predicate)
  
      ordered_closure = OrderedSet()
      to_walk = deque((0, addr) for addr in addresses)
      while len(to_walk) > 0:
        level, address = to_walk.popleft()
  
        if not walk.expand_once(address, level):
          continue
  
        target = self._target_by_address[address]
        if predicate and not predicate(target):
          continue
        if walk.do_work_once(address):
          ordered_closure.add(target)
        for dep_address in self._target_dependencies_by_address[address]:
          if walk.expanded_or_worked(dep_address):
            continue
          if walk.dep_predicate(target, self._target_by_address[dep_address], level):
            to_walk.append((level + 1, dep_address))
      return ordered_closure
docs: Returns the transitive dependency closure of `addresses` using BFS.
  
      :API: public
  
      :param list<Address> addresses: The closure of `addresses` will be walked.
      :param function predicate: If this parameter is not given, no Targets will be filtered
        out of the closure.  If it is given, any Target which fails the predicate will not be
        walked, nor will its dependencies.  Thus predicate effectively trims out any subgraph
        that would only be reachable through Targets that fail the predicate.
      :param function dep_predicate: Takes two parameters, the current target and the dependency of
        the current target. If this parameter is not given, no dependencies will be filtered
        when traversing the closure. If it is given, when the predicate fails, the edge to the dependency
        will not be expanded.