Change search space from json format to hyperopt format

def json2space(x, oldy=None, name=NodeType.Root.value):
    """Change search space from json format to hyperopt format
    """
    y = list()
    if isinstance(x, dict):
        if NodeType.Type.value in x.keys():
            _type = x[NodeType.Type.value]
            name = name + '-' + _type
            if _type == 'choice':
                if oldy != None:
                    _index = oldy[NodeType.Index.value]
                    y += json2space(x[NodeType.Value.value][_index],
                                    oldy[NodeType.Value.value], name=name+'[%d]' % _index)
                else:
                    y += json2space(x[NodeType.Value.value], None, name=name)
            y.append(name)
        else:
            for key in x.keys():
                y += json2space(x[key], (oldy[key] if oldy !=
                                         None else None), name+"[%s]" % str(key))
    elif isinstance(x, list):
        for i, x_i in enumerate(x):
            y += json2space(x_i, (oldy[i] if oldy !=
                                  None else None), name+"[%d]" % i)
    else:
        pass
    return y