public function replace(Token $oldToken, array $newTokens)
    {
        // Get the current key of the element.
        $key = array_search($oldToken, $this->registry, true);
        if (false === $key) {
            return $this;
        }
        $replacement = array();

        // Check for any non-token-elements and remove them.
        foreach ($newTokens as $token) {
            if (! $token instanceof Token) {
                continue;
            }
            $replacement[] = $token;
        }

        // Replace the old element with the newly created array
        array_splice($this->registry, $key, 1, $replacement);

        return $this;
    }