def get_create_base_agent(self, agent):
        """Return base agent with given name, creating it if needed."""
        try:
            base_agent = self.agents[_n(agent.name)]
        except KeyError:
            base_agent = BaseAgent(_n(agent.name))
            self.agents[_n(agent.name)] = base_agent

        # If it's a molecular agent
        if isinstance(agent, Agent):
            # Handle bound conditions
            for bc in agent.bound_conditions:
                bound_base_agent = self.get_create_base_agent(bc.agent)
                bound_base_agent.create_site(get_binding_site_name(agent))
                base_agent.create_site(get_binding_site_name(bc.agent))

            # Handle modification conditions
            for mc in agent.mods:
                base_agent.create_mod_site(mc)

            # Handle mutation conditions
            for mc in agent.mutations:
                res_from = mc.residue_from if mc.residue_from else 'mut'
                res_to = mc.residue_to if mc.residue_to else 'X'
                if mc.position is None:
                    mut_site_name = res_from
                else:
                    mut_site_name = res_from + mc.position

                base_agent.create_site(mut_site_name, states=['WT', res_to])

            # Handle location condition
            if agent.location is not None:
                base_agent.create_site('loc', [_n(agent.location)])

            # Handle activity
            if agent.activity is not None:
                site_name = agent.activity.activity_type
                base_agent.create_site(site_name, ['inactive', 'active'])

        # There might be overwrites here
        for db_name, db_ref in agent.db_refs.items():
            base_agent.db_refs[db_name] = db_ref

        return base_agent
Return base agent with given name, creating it if needed.