def METHOD_NAME(text, to_get='struct'):
    """Gets all struct or union definitions from text.
    Typedefed contains typedef keyword.
    """
    types_list = []
    type_re = r'(?:typedef\s+)?%s[\w\s:]*?\{(?:.*?\}[\w\s\*,]*?;){%d}'
    x = 1
    found = re.search(type_re % (to_get, x), text)
    if found is None:
        return text, types_list
    one_type = re.escape(found.group(0))
    while one_type:
        while one_type.count('{') != one_type.count('}'):
            x = x+1
            found = re.search(type_re % (to_get, x), text)
            if found is None:
                return text, types_list
            if x > 20:
                one_type = re.escape(found.group(0))
                break
            one_type = re.escape(found.group(0))
        text = re.sub(one_type, ';', text, count=1)
        if '<' not in found.group(0) and '::' not in found.group(0):
            types_list.append(found.group(0))
        x = 1
        found = re.search(type_re % (to_get, x), text)
        if found is None:
            return text, types_list
        one_type = re.escape(found.group(0))