def get_div_ids_by_level(divs, level):
    """
    Returns a list of all div ids with level.
    """
    if not isinstance(divs, list):
        divs = [divs]
    
    ids = []
    for div in divs:
        if div['level'] == level:
            ids.append(div['id'])
            # no need to check subdivs
            continue
        
        elif div['level'] > level:
            # no need to check at this level
            return ids
            
        if div.get('subdivs', None):
            subids = get_div_ids_by_level(div['subdivs'], level)
            ids.extend(subids)
            
    return ids