protected function addTaskToStage($tasks, $stage, Application $application = null, $step = 'tasks')
    {
        if (!is_array($tasks)) {
            $tasks = [$tasks];
        }

        $applicationName = $application !== null ? $application->getName() : '_';

        if (!isset($this->tasks['stage'][$applicationName][$stage][$step])) {
            $this->tasks['stage'][$applicationName][$stage][$step] = [];
        }

        $this->tasks['stage'][$applicationName][$stage][$step] = array_merge($this->tasks['stage'][$applicationName][$stage][$step], $tasks);
    }