@staticmethod
def _foldclassname(classname, width):
    """Split `classname` in newlines if the width is wider than `width`.

        >>> fold = FoldedInheritanceGraph._foldclassname
        >>> fold('aaa.bbb.ccc', 7)
        'aaa.bbb\\n.ccc'
        >>> fold('aaa.bbb.ccc', 3)
        'aaa\\n.bbb\\n.ccc'
        >>> identity = lambda x, y: ''.join(fold(x, y).split('\\n'))
        >>> identity('aaa.bbb.ccc', 7)
        'aaa.bbb.ccc'
        >>> identity('aaa.bbb.ccc', 3)
        'aaa.bbb.ccc'
        """
    parts = classname.split('.')
    lines = []
    chunk = [parts.pop(0)]
    for part in parts:
        if len('.'.join(chunk + [part])) > width:
            lines.append('.'.join(chunk))
            chunk = [part]
        else:
            chunk.append(part)
    lines.append('.'.join(chunk))
    return '\\n.'.join(lines)
