public static function countMinDepth($potentialArray, $depth = 0)
    {
        // validation, must be positive int or 0
        if (!self::isLogicallyCastableToInt($depth)) {
            throw new InvalidArgumentException('Depth parameter must be non-negative integer');
        }
        if ($depth < 0) {
            throw new InvalidArgumentException('Depth parameter must be non-negative integer');
        }

        $return = $depth;
        if (is_array($potentialArray)) {
            $return++;
            $childrenDepths = array();
            foreach ($potentialArray as $element) {
                $childrenDepths[] = self::countMinDepth($element, $return);
            }
            $return = empty($childrenDepths) ? $return : min($childrenDepths);
        }

        return $return;
    }