Respect\Validation\Exceptions\NestedValidationException::getExceptionForPath PHP Method

getExceptionForPath() private method

private getExceptionForPath ( string $path, ValidationException $exception ) : ValidationException
$path string
$exception ValidationException
return ValidationException
    private function getExceptionForPath($path, ValidationException $exception)
    {
        if ($path === $exception->guessId()) {
            return $exception;
        }
        if (!$exception instanceof self) {
            return $exception;
        }
        foreach ($exception as $subException) {
            return $subException;
        }
        return $exception;
    }