leaf_tis = [ti for ti in tis if ti.task_id in leaf_task_ids if ti.state != TaskInstanceState.REMOVED]
        
        if not unfinished.tis and any(leaf_ti.state in State.failed_states for leaf_ti in leaf_tis):
            self.log.error("Marking run %s failed", self)
            self.set_state(DagRunState.FAILED)
            self.notify_dagrun_state_changed(msg="task_failure")
            if execute_callbacks:
                dag.handle_callback(self, success=False, reason="task_failure", session=session)
            elif dag.has_on_failure_callback:
                from airflow.models.dag import DagModel
                dag_model = DagModel.get_dagmodel(dag.dag_id, session)
                callback = DagCallbackRequest(
                    full_filepath=dag.fileloc,
                    dag_id=self.dag_id,
                    run_id=self.run_id,
                    is_failure_callback=True,
                    processor_subdir=None if dag_model is None else dag_model.processor_subdir,
                    msg="task_failure",
                )
        
        elif not unfinished.tis and all(leaf_ti.state in State.success_states for leaf_ti in leaf_tis):
            self.log.info("Marking run %s successful", self)
            self.set_state(DagRunState.SUCCESS)
            self.notify_dagrun_state_changed(msg="success")
            if execute_callbacks:
                dag.handle_callback(self, success=True, reason="success", session=session)
            elif dag.has_on_success_callback:
                from airflow.models.dag import DagModel
                dag_model = DagModel.get_dagmodel(dag.dag_id, session)
                callback = DagCallbackRequest(