private function addStage($operator, $stage)
{
$lastIndex = count($this->stages) - 1;
if ($operator == '$match' && isset($this->stages[$lastIndex][$operator])) {
$this->stages[$lastIndex][$operator] = array_merge($this->stages[$lastIndex][$operator], $stage);
} else {
$this->stages[] = array($operator => $stage);
}
}