def serialize(
            self,
            value,  # type: Any
            state  # type: _ProcessorState
    ):
        # type: (...) -> ET.Element
        """Serialize the value into a new Element object and return it."""
        if self._nested is None:
            state.raise_error(InvalidRootProcessor,
                              'Cannot directly serialize a non-nested array "{}"'
                              .format(self.alias))

        if not value and self.required:
            state.raise_error(MissingValue, 'Missing required array: "{}"'.format(
                self.alias))

        start_element, end_element = _element_path_create_new(self._nested)
        self._serialize(end_element, value, state)

        return start_element
Serialize the value into a new Element object and return it.