code: def _add_modification_to_agent(agent, mod_type, residue, position):
      
      new_mod = ModCondition(mod_type, residue, position)
      # Check if this modification already exists
      for old_mod in agent.mods:
          if old_mod.equals(new_mod):
              return agent
      new_agent = deepcopy(agent)
      new_agent.mods.append(new_mod)
      return new_agent
docs: Add a modification condition to an Agent.