Mongoose: Problem populating nested array with aggregate

I have these models:

const UserSchema = new Schema({
  profile: {
    type: Schema.Types.ObjectId,
    ref: "profiles",
  },
});

And this model:

const ProfileSchema = new Schema({
  user: {
    type: Schema.Types.ObjectId,
    ref: "users",
  },
  education: [
    {
      institution: {
        type: Schema.Types.ObjectId,
        ref: "institutions",
      },
      major: {
        type: Schema.Types.ObjectId,
        ref: "majors",
      },
    },
  ],
  date: {
    type: Date,
    default: Date.now,
  },
});

I’ve been trying to populate the user.profile.education array using aggregate.
Particularly, the fields institution and major.
So the expected result is the array of education to have its education elements populated.
So the expected result should be something like this:

[
  // user 1
  {
    profile: {
      education: [
        { institution: "institution_1_data", major: "major_1_data" },
        { institution: "institution_2_data", major: "major_2_data" },
        { institution: "institution_3_data", major: "major_3_data" },
      ],
    },
  },
  // user 2
  {
    profile: {
      education: [
        { institution: "institution_1_data", major: "major_1_data" },
        { institution: "institution_2_data", major: "major_2_data" },
      ],
    },
  },
];

This is the query that I wrote:

const getUsersWithPopulatedMajorAndInstitution = async () => {
  const unwind_education_stage = {
    $unwind: "$education",
  };
  const populate_education_stage = {
    $lookup: {
      from: "majors",
      let: { major: "$education.major" },
      pipeline: [{ $match: { $expr: { $eq: ["$_id", "$$major"] } } }],
      as: "education.major",
    },
    $lookup: {
      from: "institutions",
      let: { institution: "$education.institution" },
      pipeline: [{ $match: { $expr: { $eq: ["$_id", "$$institution"] } } }],
      as: "education.institution",
    },
  };

  const populate_profile_stage = {
    $lookup: {
      from: "profiles",
      let: { profile_id: "$profile" },
      pipeline: [
        {
          $match: {
            $expr: { $eq: ["$_id", "$$profile_id"] },
          },
        },
        unwind_education_stage,
        populate_education_stage,
        {
          $project: {
            education: "$education",
          },
        },
      ],
      as: "profile",
    },
  };

  let users = await User.aggregate([populate_profile_stage]);

  return users;
};

There are two problems with this query.
PROBLEM 1:
It only populates institution because the institution $lookup stage was added after the major $lookup stage.
This makes no sense to me, as I’ve been using aggregate for a while and would expect both major and institution to be populated.

PROBLEM 2:
Using $unwind means education field would be unwinded.
So if the education array contains more than 1 education element (like the examples above), three “copies” of the user will be created and the end result is something like this:

[
  // user 1
  {
    profile: {
      education: [{ institution: "institution_1_data", major: "major_1_data" }],
    },
  },
  {
    profile: {
      education: [{ institution: "institution_2_data", major: "major_2_data" }],
    },
  },
  {
    profile: {
      education: [{ institution: "institution_3_data", major: "major_3_data" }],
    },
  },
  // user 2
  {
    profile: {
      education: [{ institution: "institution_1_data", major: "major_1_data" }],
    },
  },
  {
    profile: {
      education: [{ institution: "institution_2_data", major: "major_2_data" }],
    },
  },
];

But, that’s not the expected result as I mentioned above.
What should I change/add in the query?

I managed to achieve something that isn’t too far from what I want:

const getUsersWithPopulatedMajorAndInstitution = async (
  user_name_surname_input_value
) => {
  const unwind_education_stage = {
    $unwind: "$education",
  };

  const look_up_institution_stage = {
    $lookup: {
      from: "institutions",
      localField: "education.institution",
      foreignField: "_id",
      as: "education.institution",
    },
  };

  const look_up_major_stage = {
    $lookup: {
      from: "majors",
      localField: "education.major",
      foreignField: "_id",
      as: "education.major",
    },
  };

  const populate_stage = {
    $lookup: {
      from: "profiles",
      let: { profile_id: "$profile" },
      pipeline: [
        {
          $match: {
            $expr: { $eq: ["$_id", "$$profile_id"] },
          },
        },
        unwind_education_stage,
        look_up_major_stage,
        look_up_institution_stage,
        {
          $project: {
            education: "$education",
          },
        },
      ],
      as: "profile",
    },
  };

  let filtered_users = await User.aggregate([

    populate_stage,
  ]);

  return filtered_users;
};

That results in this:

[
  {
      "_id": "60ded1353752602bf4b364ee",
      "profile": [
          {
              "education": {
                  "_id": "62cc1b51423b0b2c02867a76",
                  "major": [
                      {
                          "_id": "60c094d603202ea0a23f970f",
                          // The rest of major data
                      }
                  ],
                  "institution": [
                      {
                          "_id": "5faf77b2acb848347a5f1ab7",
                          // The rest of institution data
                      }
                  ],
              }
          },
          {
              "_id": "60ded1363752602bf4b364ef",
              "education": {
                  "major": [
                      {
                          "_id": "60c094d603202ea0a23f970f",
                           // The rest of major data

                      }
                  ],
                  "institution": [
                      {
                          "_id": "5faf77b2acb848347a5f1ab2",
                          // The rest of institution data
                      }
                  ],
              }
          }
      ],
  }
]

It is not the exact structure I wanted. As I wanted a single array of education that contains all the populated education data.

But, still this populates user.profile.education, and returns one object per user.
So I think it’s good enough.