def remove_large_spaces(text):
    """Iteratively replace any large spaces or tabs with a single space,
    until none remain."""
    for pattern in ['\t', '  ']:
        while pattern in text:
            text = text.replace(pattern, ' ')
    while text.startswith(' '):
        text = text[1:]
    while text.endswith(' '):
        text = text[:-1]
    return text