<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _iterate_rules(rules, topology, max_iter):
 """Iteratively run all the rules until the white- and backlists converge. Parameters rules : dict A dictionary mapping rule names (typically atomtype names) to SMARTSGraphs that evaluate those rules. topology : simtk.openmm.app.Topology The topology that we are trying to atomtype. max_iter : int The maximum number of iterations. """

    atoms = list(topology.atoms())
    for _ in range(max_iter):
        max_iter -= 1
        found_something = False
        for rule in rules.values():
            for match_index in rule.find_matches(topology):
                atom = atoms[match_index]
                if rule.name not in atom.whitelist:
                    atom.whitelist.add(rule.name)
                    atom.blacklist |= rule.overrides
                    found_something = True
        if not found_something:
            break
    else:
        warn("Reached maximum iterations. Something probably went wrong.")