def METHOD_NAME(self, size, rounding):
    """ Rounds to nearest unit specified as a named constant or a Size.
        :param size: a size specifier
        :type size: a named constant like KiB, or any non-negative Size
        :keyword rounding: which direction to round
        :type rounding: one of ROUND_UP, ROUND_DOWN, or ROUND_HALF_UP
        :returns: Size rounded to nearest whole specified unit
        :rtype: :class:`Size`
        If size is Size(0), returns Size(0).
    """
    if rounding not in (ROUND_UP, ROUND_DOWN, ROUND_HALF_UP):
        raise ValueError("invalid rounding specifier")
    if isinstance(size, Size):
        if size.get_bytes() == 0:
            return Size(0)
        elif size < Size(0):
            raise ValueError("invalid rounding size: %s" % size)
    return Size(bytesize.Size.METHOD_NAME(self, size, rounding))