def _traverse(block):
    """
    Implements common logic used by ``validate_*`` methods.
    """
    def method(path, data, pointer=''):
        errors = 0

        if isinstance(data, list):
            for index, item in enumerate(data):
                errors += method(path, item, pointer=f'{pointer}/{index}')
        elif isinstance(data, dict):
            errors += block(path, data, pointer)

            for key, value in data.items():
                errors += method(path, value, pointer=f'{pointer}/{key}')

        return errors

    return method