import re


def camel_case_to_underscore(name):
    """
    Converts name from CamelCase to snake_case
    """
    # the two steps are needed to support words with sequences of more than
    # one uppercase character
    step1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
    return re.sub('([a-z0-9])([A-Z])', r'\1_\2', step1).lower()