def prune_view_references(view_refs):
    """Removes all empty entries and branches from view_reference tree"""
    pruned_refs = {}
    for layer_name, views in view_refs.items():
        layer_refs = {}
        if views is None:
            continue
        for view_name, setofthings in views.items():
            if setofthings:
                layer_refs[view_name] = setofthings

        if layer_refs:
            pruned_refs[layer_name] = layer_refs
    return pruned_refs