public void merge(RoutingContext ctx) {
            Reply ret = new EmptyReply();
            int idx = 0;
            int idxFirstOk = -1;
            for (RoutingNodeIterator it = ctx.getChildIterator();
                 it.isValid(); it.next(), ++idx) {
                Reply ref = it.getReplyRef();
                if (!ref.hasErrors()) {
                    if (idxFirstOk < 0) {
                        idxFirstOk = idx;
                    }
                } else {
                    for (int i = 0; i < ref.getNumErrors(); ++i) {
                        Error err = ref.getError(i);
                        if (!errorMask.contains(err.getCode())) {
                            ret.addError(err);
                        }
                    }
                }
            }
            if (ret.hasErrors()) {
                ctx.setReply(ret);
            } else {
                ctx.setReply(ctx.getChildIterator().skip(idxFirstOk).removeReply());
            }
        }
@author havardpe
@author Simon Thoresen Hult
messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingTestCase.java