public function append($other): self
    {
        if (is_array($this->elements) && !is_array($other) && !($other instanceof \Traversable)) {
            $all = $this->elements;
            $all[] = $other;
            return new self($all);
        }

        $appendIterator = new \AppendIterator();
        $appendIterator->append($this->getIterator());
        $appendIterator->append(castToIterator($other));
        return new self($appendIterator, $this->type);
    }