protected function arrayDepth($element, $depth = 1) {
        if (is_array($element)) {
            $maxDepth = $depth;
            foreach($element as $el) {
                $d = $this->arrayDepth($el, $depth + 1);
                if ($d > $maxDepth) {
                    $maxDepth = $d;
                }
            }
            return $maxDepth;
        } else {
            return $depth;
        }
    }