Return the parameter list from api for defined path and HTTP method

def _get_properties(path="", method="GET", forced_params=None):
    '''
    Return the parameter list from api for defined path and HTTP method
    '''
    if api is None:
        _import_api()

    sub = api
    path_levels = [level for level in path.split('/') if level != '']
    search_path = ''
    props = []
    parameters = set([] if forced_params is None else forced_params)
    # Browse all path elements but last
    for elem in path_levels[:-1]:
        search_path += '/' + elem
        # Lookup for a dictionary with path = "requested path" in list" and return its children
        sub = (item for item in sub if item["path"] == search_path).next()['children']
    # Get leaf element in path
    search_path += '/' + path_levels[-1]
    sub = next((item for item in sub if item["path"] == search_path))
    try:
        # get list of properties for requested method
        props = sub['info'][method]['parameters']['properties'].keys()
    except KeyError as exc:
        log.error('method not found: "%s"', exc)
    for prop in props:
        numerical = re.match(r'(\w+)\[n\]', prop)
        # generate (arbitrarily) 10 properties for duplicatable properties identified by:
        # "prop[n]"
        if numerical:
            for i in range(10):
                parameters.add(numerical.group(1) + six.text_type(i))
        else:
            parameters.add(prop)
    return parameters