def METHOD_NAME(  # type:ignore[override]
    self, head_subject, tail_subject
) -> UML.Association | None:
    line = self.line
    subject = line.subject
    def member_ends_match(subject):
        return len(subject.memberEnd) >= 2 and (
            (
                head_subject is subject.memberEnd[0].type
                and tail_subject is subject.memberEnd[1].type
            )
            or (
                head_subject is subject.memberEnd[1].type
                and tail_subject is subject.memberEnd[0].type
            )
        )
    # First check if the right subject is already connected:
    if line.subject and member_ends_match(line.subject):
        return subject
    diagram = self.diagram
    return next(
        (
            a
            for a in line.model.select(UML.Association)
            if member_ends_match(a) and diagram not in a.presentation[:].diagram
        ),
        None,
    )