def filter(nodes, labels=[]):
    """Filter nodes which matches labels"""
    labels = set(labels)
    filterd_nodes = {}
    for k, spec in nodes.items():
        node_labels = set(spec.get('labels', []))
        matched_labels = labels & node_labels
        if matched_labels == labels:
            filterd_nodes[k] = spec
    return filterd_nodes