public function flatten()
    {
        $flattenedArray = [];
        array_walk_recursive($this->array, function ($item) use (&$flattenedArray) {
            $flattenedArray[] = $item;
        });
        $newInstance = new self();
        $newInstance->setArray($flattenedArray);
        return $newInstance;
    }