<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _parse_type(self, element, types):
 """Parse a 'complexType' element. @param element: The top-level complexType element @param types: A map of the elements of all available complexType's. @return: The schema for the complexType. """

        name = element.attrib["name"]
        type = element.attrib["type"]
        if not type.startswith("tns:"):
            raise RuntimeError("Unexpected element type %s" % type)
        type = type[4:]

        [children] = types[type][0]
        types[type][1] = True

        self._remove_namespace_from_tag(children)
        if children.tag not in ("sequence", "choice"):
            raise RuntimeError("Unexpected children type %s" % children.tag)

        if children[0].attrib["name"] == "item":
            schema = SequenceSchema(name)
        else:
            schema = NodeSchema(name)

        for child in children:
            self._remove_namespace_from_tag(child)
            if child.tag == "element":
                name, type, min_occurs, max_occurs = self._parse_child(child)
                if type in self.leaf_types:
                    if max_occurs != 1:
                        raise RuntimeError("Unexpected max value for leaf")
                    if not isinstance(schema, NodeSchema):
                        raise RuntimeError("Attempt to add leaf to a non-node")
                    schema.add(LeafSchema(name), min_occurs=min_occurs)
                else:
                    if name == "item":  # sequence
                        if not isinstance(schema, SequenceSchema):
                            raise RuntimeError("Attempt to set child for "
                                               "non-sequence")
                        schema.set(self._parse_type(child, types),
                                   min_occurs=min_occurs,
                                   max_occurs=max_occurs)
                    else:
                        if max_occurs != 1:
                            raise RuntimeError("Unexpected max for node")
                        if not isinstance(schema, NodeSchema):
                            raise RuntimeError("Unexpected schema type")
                        schema.add(self._parse_type(child, types),
                                   min_occurs=min_occurs)
            elif child.tag == "choice":
                pass
            else:
                raise RuntimeError("Unexpected child type")
        return schema