def parse_dates(tree_to_parse, xpath_map):
    """
    Creates and returns a Dates Dictionary data structure given the parameters provided
    :param tree_to_parse: the XML tree from which to construct the Dates data structure
    :param xpath_map: a map containing the following type-specific XPATHs:
        multiple, range, range_begin, range_end, and single
    """

    # Determine dates to query based on metadata elements

    values = wrap_value(parse_property(tree_to_parse, None, xpath_map, DATE_TYPE_SINGLE))
    if len(values) == 1:
        return {DATE_TYPE: DATE_TYPE_SINGLE, DATE_VALUES: values}
    elif len(values) > 1:
        return {DATE_TYPE: DATE_TYPE_MULTIPLE, DATE_VALUES: values}

    values = wrap_value(parse_property(tree_to_parse, None, xpath_map, DATE_TYPE_MULTIPLE))
    if len(values) == 1:
        return {DATE_TYPE: DATE_TYPE_SINGLE, DATE_VALUES: values}
    elif len(values) > 1:
        return {DATE_TYPE: DATE_TYPE_MULTIPLE, DATE_VALUES: values}

    values = flatten_items(
        d for x in (DATE_TYPE_RANGE_BEGIN, DATE_TYPE_RANGE_END)
        for d in wrap_value(parse_property(tree_to_parse, None, xpath_map, x))
    )
    if len(values) == 1:
        return {DATE_TYPE: DATE_TYPE_SINGLE, DATE_VALUES: values}
    elif len(values) == 2:
        return {DATE_TYPE: DATE_TYPE_RANGE, DATE_VALUES: values}
    elif len(values) > 2:
        return {DATE_TYPE: DATE_TYPE_MULTIPLE, DATE_VALUES: values}

    return {}
Creates and returns a Dates Dictionary data structure given the parameters provided
    :param tree_to_parse: the XML tree from which to construct the Dates data structure
    :param xpath_map: a map containing the following type-specific XPATHs:
        multiple, range, range_begin, range_end, and single