Where do people get the saying, "the bad palm tree goes off and joins the barren palms"? This matter is written in the Torah, repeated in the Prophets, stated a third time in the Writings, taught in the Mishnah, and taught in a baraita. Written in the Torah: "And Esau went to Ishmael." Repeated in the Prophets (Judges 11:3): "And there gathered to Jephthah worthless men." A third time in the Writings (Ben Sira 13): "Every bird dwells with its own kind, and a man with one like himself." Taught in the Mishnah: that which is joined to the impure is impure, to the pure is pure. Taught in a baraita: Rabbi Eliezer says, not for nothing did the starling go to the raven, but because it is of its kind. Rabbi Yudan in the name of Rabbi Aivo (Proverbs 12:13): "In the transgression of the lips is an evil snare": from the rebellion that Esau and Ishmael rebelled against the Holy One, blessed be He, came a stumbling block to them, "but the righteous escapes from trouble" (same verse), this is Jacob, "and Jacob went out from Beersheba and went toward Haran."
Esau Goes to Ishmael and Birds of a Feather Flock Together
Yalkut Shimoni on Torah 116:2
מְנָּא הָא מִּלְתָא דְּאַמְרֵי אִינְשֵׁי מְטַיֵּל וְאָזִיל דִיקְלָא בִּישְׁתָא גַּבֵּי קִינָא דְשַׂרְכֵי, דָּבָר זֶה כָּתוּב בַּתּוֹרָה, וְשָׁנּוּי בַּנְּבִיאִים, וּמְשֻׁלָּשׁ בַּכְּתוּבִים. תָּנִי בְּמַתְנִיתִין, וְתַּנְיָא בִּבְרַיְתָא. כָּתוּב בַּתּוֹרָה, וַיֵּלֶךְ עֵשָׂו אֶל יִשְׁמָעֵאל. שָׁנּוּי בַּנְּבִיאִים (שופטים יא, ג) "וַיִתְלַקְּטּוּ אֶל יִפְתָּח אֲנָשִׁים רֵיקִים". מְשֻׁלָּשׁ בַּכְּתוּבִים, (בן סירא יג) "כָּל עוֹף לְמִינוֹ יִשְׁכּוֹן וּבֶן אָדָם לַדּוֹמֶה לוֹ". תָּנִי בְּמַתְנִיתִין, הַמְחֻבָּר לַטָּמֵא טָמֵא לַטָּהוֹר טָהוֹר. וְתַנְיָא בִּבְרַיְתָא, רַבִּי אֱלִיעֶזֶר אוֹמֵר, לֹא לְחִנָּם הָלַךְ זַרְזִיר אֵצֶל עוֹרֵב אֶלָּא מִפְּנֵי שֶׁהוּא מִינוֹ. רַבִּי יוּדָן בְּשֵׁם רַבִּי אֵיְבוֹ (משלי יב, יג) "בְּפֶשַׁע שְׂפָתַיִם מוֹקֵשׁ רָע", מִמֶּרֶד שֶׁמָּרַד עֵשָׂו וְיִשְׁמָעֵאל בַּהַקָּדוֹשׁ בָּרוּךְ הוּא בָּאת לָהֶם תַּקָּלָה, "וְיֵצֵא מִצָּרָה צַדִּיק", זֶה יַעֲקֹב, וַיֵּצֵא יַעֲקֹב מִבְּאֵר שָׁבַע וַיֵּלֶךְ חָרָנָה.