import re


def _clear_fields(template):
    """
    Converts {0}, {1}, {2}, etc to {}, {{}}, {{{{}}}}, etc. to allow recursive formatting.
    """


    matcher = r'\{(\d+)\}'
    fit = re.finditer(matcher, template)
    res = template
    for inst in fit:
        num = int(inst.group(1))
        res = res.replace(inst.group(0), ('{' * (2**num))+('}' * (2**num)), 1)
    return res