def cut_levels(nodes, start_level):
    final = []
    removed = []
    for node in nodes:
        if not hasattr(node, 'level'):
            remove(node, removed)
            continue
        if node.attr.get('soft_root', False):
            remove(node, removed)
            continue
        if node.level == start_level:
            final.append(node)
            node.parent = None
            if not node.visible and not node.children:
                remove(node, removed)
        elif node.level == start_level + 1:
            node.children = []
        else:
            remove(node, removed)
        if not node.visible:
            keep_node = False
            for child in node.children:
                keep_node = keep_node or child.visible
            if not keep_node:
                remove(node, removed)
    for node in removed:
        if node in final:
            final.remove(node)
    return final