public static void optimizeByRestrict(Query query) {
        if (query.getModel().getRestrict().size() != 1) {
            return;
        }
        Item root = query.getModel().getQueryTree().getRoot();

        if (optimizeByRestrict(root, query.getModel().getRestrict().iterator().next()) == Recall.RECALLS_NOTHING) {
            query.getModel().getQueryTree().setRoot(new NullItem());
        }
    }
Optimizes the given query tree based on its {@link Model#getRestrict()} parameter, if any.
container-search/src/main/java/com/yahoo/prelude/querytransform/QueryRewrite.java