Parse aggregate pipeline to match objects with a valid pointer field

const query = new Parse.Query("TimeSpent");
const pipeline = [
    {
        $match: {
            date: {
                $gte: new Date(startDate),
                $lte: new Date(endDate)
            },
            parent: { $exists: true }
        }
    },        
    {
        $group: {
            _id: '$staff',
            minutes: { $sum: "$minutes" }
        }
    }
];    

try {        
    const results = await query.aggregate(pipeline);      
    return results;
} catch (error) {
    console.error('Error while aggregating:', error);
}

I have a parse pipeline code that aggregates the time spent per staff based on a Class “TimeSpent”. This class has “parent” field which is a Pointer that points to some sort of parent.

In the $match phase, I want to ignore the objects if they do not have a parent field, or for some reason the parent object is deleted, or non-existent.

Currenltly by setting parent: { $exists: true } it doesn’t know if the parent pointer is pointing to something or not.

How to improve this code?