def get_or_create_student(self, name, LSAT, GPA): if name in self.students: return self.students[name] else: current_student = Student(name) current_student.LSAT = LSAT current_student.GPA = GPA for existing_student in self.students.itervalues(): if is_peer(current_student, existing_student): current_student.add_peer(existing_student) existing_student.add_peer(current_student) self.students[name] = current_student return current_student