def _extract_element(xml, element_name, namespace):
    """
    An internal method provided to extract an element from the given XML.

    :type  xml: :class:`str`
    :param xml: The XML string from which the element will be extracted.
    :type  element_name: :class:`str`
    :param element_name: The element that needs to be extracted from the XML.
    :type  namespace: :class:`dict`
    :param namespace: A dict containing the namespace of the element to be
        extracted.
    :rtype: etree element.
    :return: The extracted element.
    """
    assert(len(namespace) == 1)
    result = xml.xpath("//%s:%s" % (list(namespace.keys())[0], element_name),
                       namespaces=namespace)
    if result and len(result) == 1:
        return result[0]
    else:
        raise KeyError("%s does not seem to be present or valid in the XML." %
                       element_name)