code: def find_agency(self, agent_id):
          
  
          def has_agent(agency):
              for agent in agency._agents:
                  if agent._descriptor.doc_id == agent_id:
                      return True
              return False
  
          matching = filter(has_agent, self._agencies)
          if len(matching) > 0:
              self.debug('Find agency returns %dth agency.',
                         self._agencies.index(matching[0]))
              return matching[0]
docs: Returns the agency running the agent with agent_id or None.