def _validate(data_type, parent_path):
    """Implementation for the `validate` function."""
    if isinstance(data_type, _CLASS_TYPES):
        raise TypeError(
            "The data type is expected to be an instance object, but got the "
            "type '%s' instead." % (_format_type(data_type),))

    base = _find_base_type(data_type)
    if not base:
        raise TypeError(
            "Objects of type '%s' aren't supported as data types. Use any "
            "type from %s instead."
            % (_format_type(type(data_type)), _join_types(_ALL, "or ")))

    name = getattr(data_type, 'name', None)
    if not name:
        name = type(data_type).__name__

    full_path = '%s.%s' % (parent_path, name) if parent_path else name

    # Generic checks for each attribute.
    for check in _TYPE_ATTR_CHECKS[base]:
        attribute = getattr(data_type, check.name)
        if attribute is None:
            if check.allow_none:
                continue
            else:
                raise TypeError("The attribute '%s.%s' cannot be 'None'."
                                % (full_path, check.name))

        if isinstance(check, _FieldInstanceCheck):
            check_function = isinstance
        elif isinstance(check, _FieldSubclassCheck):
            if not isinstance(attribute, _CLASS_TYPES):
                raise TypeError(
                    "The attribute '%s.%s' is expected to be a type "
                    "object%s." % (full_path, check.name,
                                   " or 'None'" if check.allow_none else ''))

            check_function = issubclass

        if not check_function(attribute, check.type):
            if isinstance(check, _FieldInstanceCheck):
                glue_1 = "an instance object of type"
                glue_2 = "not"
                glue_3 = ""
                type_name = _format_type(type(attribute))
            elif isinstance(check, _FieldSubclassCheck):
                glue_1 = "a subclass of"
                glue_2 = "but got"
                glue_3 = " instead"
                type_name = _format_type(attribute)

            raise TypeError(
                "The attribute '%s.%s' is expected to be %s %s, %s '%s'%s."
                % (full_path, check.name, glue_1,
                   _join_types(check.type, "or "), glue_2, type_name, glue_3))

    # Additional and/or recursive checks for specific attributes.
    if isinstance(data_type, Array):
        _validate(data_type.element_type, full_path)
    elif isinstance(data_type, Structure):
        for field in data_type.fields:
            if not isinstance(field, _SEQUENCE_TYPES):
                raise TypeError(
                    "Each field from the attribute '%s.fields' is expected "
                    "to be an instance object of type %s, not '%s'."
                    % (full_path,
                       _join_types(_SEQUENCE_TYPES + (Field,), "or "),
                       _format_type(type(field))))

            if len(field) not in _FIELD_REQUIRED_ARG_RANGE:
                raise TypeError(
                    "Each field from the attribute '%s.fields' is expected "
                    "to be an instance object of type %s, and compatible with "
                    "the '%s' structure, but got %r instead."
                    % (full_path,
                       _join_types(_SEQUENCE_TYPES + (Field,), "or "),
                       _format_type(Field), field))

            field = Field(*field)
            if not isinstance(field.name, _STRING_TYPES):
                raise TypeError(
                    "The first element of each field from the attribute "
                    "'%s.fields', that is the 'name' attribute, is expected "
                    "to be an instance object of type %s, not '%s'."
                    % (full_path, _join_types(_STRING_TYPES, "or "),
                       _format_type(type(field.name))))

            if not isinstance(field.type, _ALL):
                raise TypeError(
                    "The second element of each field from the attribute "
                    "'%s.fields', that is the 'type' attribute, is expected "
                    "to be an instance object of type %s, not '%s'."
                    % (full_path, _join_types(_ALL, "or "),
                       _format_type(type(field.type))))

            if not isinstance(field.read_only, bool):
                raise TypeError(
                    "The third element of each field from the attribute "
                    "'%s.fields', that is the 'read_only' attribute, is "
                    "expected to be an instance object of type 'bool', "
                    "not '%s'." % (full_path,
                                   _format_type(type(field.read_only))))

            field_path = '%s.%s' % (full_path, field.name)
            _validate(field.type, field_path)

        fields = [field[_FIELD_NAME_IDX] for field in data_type.fields]
        duplicates = _find_duplicates(fields)
        if duplicates:
            if len(duplicates) > 1:
                raise ValueError(
                    "The structure fields %s, were provided multiple times."
                    % (_join_sequence(duplicates, "and ")),)
            else:
                raise ValueError(
                    "The structure field '%s' was provided multiple times."
                    % (duplicates[0]),)

    return True
Implementation for the `validate` function.