def highest_atom_indices(r):
    """
    Returns a dictionary with highest atom indices in given residue
    Key: value -> element.name: highest index in residue
    """
    results = {'C': 0, 'H': 0, 'N': 0, 'O': 0}
    for a in r.atoms:
        if a.name[1:].isdigit():
            atom = a.name[:1]
            num = int(a.name[1:])
            if atom not in results:
                results[atom] = num
            elif results[atom] < num:
                results[atom] = num

        elif a.name[2:].isdigit():
            atom = a.name[:2]
            num = int(a.name[2:])
            if atom not in results:
                results[atom] = num
            elif results[atom] < num:
                results[atom] = num
    return results