Using the code in the related post, consider what happens when adjacent_find sends left=(22,A) and right=(22,A) to isDistEqual(). The distances match, but the student ID do not match and so
left.studentName != right.studentName
is false. So this pair is skipped by adjacent_find.
So, you won't even know from adjacent_find that there even were two entries = (22,A). So, you don't have to worry about getting 22 feet: A, A, C, D since 22,A will be seen only once.