private function getDocumentStream($xmlDocument)
    {
        /**
         * @var StreamAdapterInterface $streamAdapter
         */
        foreach ($this->streamAdapters as $streamAdapter) {

            if ($streamAdapter->supports($xmlDocument)) {
                return $streamAdapter->convert($xmlDocument);
            }
        }

        throw new RuntimeException(sprintf('Suitable XML document stream adapter is not registered for XML document of type "%s".', is_object($xmlDocument) ? get_class($xmlDocument) : gettype($xmlDocument)));
    }