In the Aarne–Thompson–Uther folktale classification system, the story and its variants count as tale type 514, "The Shift in Sex". Scholars often interpret them as tales of transgender identity and transition.
TIL that there is something like a "tale type xyz".