private function isTooDeep(Context $context) { $depth = $context->getDepth(); $metadataStack = $context->getMetadataStack(); $nthProperty = 1; foreach ($metadataStack as $metadata) { $relativeDepth = $depth - ++$nthProperty; if (null !== $metadata->maxDepth && $relativeDepth > $metadata->maxDepth) { return true; } } return false; }