public function getStats()
    {
        $this->resetTotals();
        foreach ($this->flow->getNodes() as $node) {
            $nodeMap = $this->nodeMap[$node->getId()];
            foreach ($this->incrementTotals as $srcKey => $totalKey) {
                if (isset($nodeMap[$srcKey])) {
                    $this->flowStats[$totalKey] += $nodeMap[$srcKey];
                }
            }

            if ($node instanceof BranchNodeInterface) {
                $childFlowId                               = $node->getPayload()->getId();
                $this->flowStats['branches'][$childFlowId] = $node->getPayload()->getStats();
                foreach ($this->incrementTotals as $srcKey => $totalKey) {
                    if (isset($this->flowStats['branches'][$childFlowId][$totalKey])) {
                        $this->flowStats[$totalKey] += $this->flowStats['branches'][$childFlowId][$totalKey];
                    }
                }
            }
        }

        $flowStatus = $this->flow->getFlowStatus();
        if ($flowStatus !== null) {
            $this->flowStats['flow_status'] = $flowStatus->getStatus();
        }

        return $this->flowStats;
    }