count += encodeTransactionLine(tree, transaction, buf, locator, ruler);
int len = children.size();
for (int i = 0; i < len; i++) {
Message child = children.get(i);
locator.setLast(i == len - 1);
if (child instanceof Transaction) {
count += encodeTransaction(tree, (Transaction) child, buf, locator, ruler);
} else if (child instanceof Event && "RemoteCall".equals(child.getType())) {
count += encodeRemoteCall(tree, (Event) child, buf, locator, ruler);
}
}
locator.upLevel();