code: def map_agent(self, agent, do_rename):
          agent_text = agent.db_refs.get('TEXT')
          mapped_to_agent_json = self.agent_map.get(agent_text)
          if mapped_to_agent_json:
              mapped_to_agent = \
                  Agent._from_json(mapped_to_agent_json['agent'])
              return mapped_to_agent, False
          if agent_text in self.gm.keys():
              map_db_refs = self.gm[agent_text]
          else:
              return agent, False
          if map_db_refs is None:
              logger.debug("Skipping %s" % agent_text)
              return None, True
          else:
              self.update_agent_db_refs(agent, agent_text, do_rename)
          return agent, False