'Handle a parent match
:param match:
:type match:
:param yield_parent:
:type yield_parent:
:return:
:rtype:'

def _match_parent(self, match, yield_parent):

    ret = super(Chain, self)._match_parent(match, yield_parent)
    original_children = Matches(match.children)
    original_end = match.end
    while ((not ret) and match.children):
        last_pattern = match.children[(-1)].pattern
        last_pattern_children = [child for child in match.children if (child.pattern == last_pattern)]
        last_pattern_groups_iter = itertools.groupby(last_pattern_children, (lambda child: child.match_index))
        last_pattern_groups = {}
        for (index, matches) in last_pattern_groups_iter:
            last_pattern_groups[index] = list(matches)
        for index in reversed(list(last_pattern_groups)):
            last_matches = list(last_pattern_groups[index])
            for last_match in last_matches:
                match.children.remove(last_match)
            match.end = (match.children[(-1)].end if match.children else match.start)
            ret = super(Chain, self)._match_parent(match, yield_parent)
            if ret:
                return True
    match.children = original_children
    match.end = original_end
    return ret
