private function calculateRequiredSizes(array $value): array
    {
        $sizes = [];
        while (is_array($value)) {
            $sizes[] = count($value);
            if (!count($value) || array_keys($value) !== range(0, count($value) - 1)) {
                if (0 === $this->itemConverter->dimensions()) {
                    // scalar base type? "weird" sub-array is not allowed
                    throw TypeConversionException::unexpectedValue(
                        $this,
                        'output',
                        'non-empty array with 0-based numeric indexes',
                        $value
                    );
                }
                // assume that we reached an array representing base type
                array_pop($sizes);
                return $sizes;
            }
            if (null === ($value = $value[0])) {
                // null sub-arrays are not allowed, so that should be a base-type null
                return $sizes;
            }
        }
        if ($this->itemConverter->dimensions() > 0) {
            // check whether we have an object representing base type
            if (is_object($value)) {
                try {
                    $this->itemConverter->output($value);
                    return $sizes;
                } catch (PackageException $e) {
                }
            }
            array_splice($sizes, -$this->itemConverter->dimensions());
        }
        return $sizes;
    }