code: private byte[] encodeScatterMsgForNode(final TopologySimpleNode node,
                                           final Map<String, byte[]> taskIdToBytes) {
  
      try (final ByteArrayOutputStream bstream = new ByteArrayOutputStream();
           final DataOutputStream dstream = new DataOutputStream(bstream)) {
  
        // first write the node's encoded data
        final String taskId = node.getTaskId();
        if (taskIdToBytes.containsKey(taskId)) {
          dstream.write(taskIdToBytes.get(node.getTaskId()));
  
        } else {
          // in case mapOfTaskToBytes does not contain this node's id, write an empty
          // message (zero elements)
          dstream.writeInt(0);
        }
  
        // and then write its children's identifiers and their encoded data
        for (final TopologySimpleNode child : node.getChildren()) {
          dstream.writeUTF(child.getTaskId());
          final byte[] childData = encodeScatterMsgForNode(child, taskIdToBytes);
          dstream.writeInt(childData.length);
          dstream.write(childData);
        }
  
        return bstream.toByteArray();
  
      } catch (final IOException e) {
        throw new RuntimeException("IOException", e);
      }
    }
docs: Compute a single byte array message for a node and its children.
  Using {@code taskIdToBytes}, we pack all messages for a
  {@code TopologySimpleNode} and its children into a single byte array.
  
  @param node the target TopologySimpleNode to generate a message for
  @param taskIdToBytes map containing byte array of encoded data for individual Tasks
  @return single byte array message