Get the right value from the scikit-tree

def _get_value(scikit_value, mode = 'regressor', scaling = 1.0, n_classes = 2, tree_index = 0):
    """ Get the right value from the scikit-tree
    """
    # Regression
    if mode == 'regressor':
        return scikit_value[0] * scaling

    # Binary classification
    if n_classes == 2:
        # Decision tree
        if len(scikit_value[0]) != 1:
            value = scikit_value[0][1] * scaling / scikit_value[0].sum()
        # boosted tree
        else:
            value = scikit_value[0][0] * scaling
        if value == 0.5:
            value = value - 1e-7

    # Multiclass classification
    else:
        # Decision tree
        if len(scikit_value[0]) != 1:
            value = scikit_value[0] / scikit_value[0].sum()
        # boosted tree
        else:
            value = {tree_index: scikit_value[0] * scaling}
    return value