Yevamos, chapter eleven, mishnah 4. This mishnah, like the previous one, deals with two women whose children became mixed up so that it is not known which child belongs to which mother. Here, however, a unique set of complications arises, because the two women do not share the same status relative to one another.
The words of the mishnah: "HaIshah shenisarev veladah bivlad kallasah" - a woman whose newborn son became mixed up with the newborn son of her daughter-in-law, her son's wife. Each of them also has other sons whose identity is certain and whose lineage is not in doubt.
When the mixed-up sons died:
"Higdilu haTaaruvos venasu nashim umeisu" - the two sons who had been mixed up grew up, married, and died, and now their widows come before the sons whose identity is certain:
"Benei hakallah cholzin velo meyabmin" - the certain sons of the daughter-in-law perform chalitzah for both widows and do not perform yibum, "shehu safek eishes achiv usefek eishes achi aviv": if the deceased was the daughter-in-law's son, he is their brother, the widow is their yevamah, and there is a mitzvah to marry her; but if he was the older woman's son, then the deceased is their father's brother, and the widow is the wife of their father's brother - a forbidden relationship. Because of the doubt they do not perform yibum, but only chalitzah.
"Uvenei zekeinah o cholzin o meyabmin" - the certain sons of the older woman, the mother-in-law, may either perform chalitzah or perform yibum, since each widow is "safek eishes achiv ve'eishes ben achiv": if the deceased was the older woman's son, he is their brother and there is a mitzvah of yibum here; and if he was the daughter-in-law's son, he is the son of their brother, and the widow is the wife of their nephew - permitted to them and not a forbidden relationship. There is therefore no mitzvah of yibum here, but there is also no prohibition at all, and so they are free to perform either chalitzah or yibum.
When the sons of certain lineage died:
The mishnah now takes up the reverse case: "Meisu haKesheirim" - the sons of certain lineage, whose parents are known, died, and the mixed-up sons are the ones who remain alive:
The widows of the older woman's sons: the mixed-up sons perform chalitzah and do not perform yibum, since each of these widows is possibly the wife of his brother: if the one performing yibum is the older woman's son, then the deceased is his brother, the widow is his yevamah, and there is a mitzvah to marry her; but if he is the daughter-in-law's son, then the deceased is his father's brother, and the widow is the wife of his father's brother - a forbidden relationship.
The widows of the daughter-in-law's sons: one performs chalitzah and the other performs yibum, because here there is no concern of violating a forbidden relationship at all: regarding the widows of the daughter-in-law's sons, if the one performing yibum is not the brother of the deceased, then she is the wife of his nephew - and there is no prohibition of a forbidden relationship in her case.
Therefore one of the sons first performs chalitzah, and afterward the second performs yibum. In this way the widows are released in every case, for they received chalitzah from one and yibum from the other, and regardless of which of them is the true yavam - they received either chalitzah or yibum.