def METHOD_NAME(textblock, wrap_width, side='right'):
    """Wraps overflowing text of TextBlock2D with respect to width.
    Parameters
    ----------
    textblock : TextBlock2D
        The textblock object whose text needs to be wrapped.
    wrap_width : int
        Required width of the wrapped text.
    side : str, optional
        Clips the overflowing text according to side.
        It takes values "left" or "right".
    Returns
    -------
    wrapped text : str
        Wrapped version of the text.
    """
    original_str = textblock.message
    str_copy = textblock.message
    wrap_idxs = []
    wrap_idx = check_overflow(textblock, wrap_width, '', side)
    if wrap_idx == 0:
        return original_str
    wrap_idxs.append(wrap_idx)
    while wrap_idx != 0:
        str_copy = str_copy[wrap_idx:]
        textblock.message = str_copy
        wrap_idx = check_overflow(textblock, wrap_width, '', side)
        if wrap_idx != 0:
            wrap_idxs.append(wrap_idxs[-1] + wrap_idx + 1)
    for idx in wrap_idxs:
        original_str = original_str[:idx] + '\n' + original_str[idx:]
    textblock.message = original_str
    return textblock.message