public function execute($data = null)
    {
        if ($this->getEndMiddleware()) {
            $end = $this->getEndMiddleware();

            if (count($this->stack)) {
                $this->stack->bottom()->setNext($end);
            }

            $this->stack->unshift($end);
        }

        if (!count($this->stack)) {
            return null;
        }

        // Start call chaining.
        $result = $this->stack->top()->execute($data);

        // Remove end middleware so we can re-use this chain.
        if ($this->getEndMiddleware()) {
            $this->stack->shift();
        }

        return $result;
    }