When a dictionary key is optional/optionalnull/mandatory, its corresponding
    _value_ is decorated in an Optional/OptionalNull/Mandatory tuple.
    This function undo the decoration when necessary.

def _qualify_map(key, content):
    """
    When a dictionary key is optional/optionalnull/mandatory, its corresponding
    _value_ is decorated in an Optional/OptionalNull/Mandatory tuple.
    This function undo the decoration when necessary.
    """
    if not isinstance(key, basestring):
        return key, content

    min_len  = None
    max_len  = None
    modifier = []
    m        = RE_MATCH_CSTR(key)

    if not m:
        raise KeyError("Unable to parse, invalid key: %r" % key)

    if m.group(3) is not None:
        min_len = max_len = int(m.group(3))
    elif m.group(4) is not None:
        if m.group(4):
            min_len = int(m.group(4))
        else:
            min_len = 0
        if m.group(5):
            max_len = int(m.group(5))
    elif m.group(6) == '*':
        min_len = 0
    elif m.group(6) == '+':
        min_len = 1
    elif m.group(6) == '?':
        min_len = 0
        max_len = 1

    if m.group(7):
        modifier = m.group(7).split(',')

    if m.group(8) == '-':
        modifier.append('strip')

    if m.group(2) == '*':
        return m.group(1), OptionalNull(content, min_len, max_len, modifier)
    elif m.group(2) == '?':
        return m.group(1), Optional(content, min_len, max_len, modifier)
    elif m.group(2) == '+':
        return m.group(1), Mandatory(content, min_len, max_len, modifier)
    else:
        return m.group(1), Mandatory(content, min_len, max_len, modifier)