def toProtocolTreeNode(self): node = super(EncryptedMessageProtocolEntity, self).toProtocolTreeNode() participantsNode = ProtocolTreeNode("participants") for enc in self.encEntities: encNode = enc.toProtocolTreeNode() if encNode.tag == "to": participantsNode.addChild(encNode) else: node.addChild(encNode) if len(participantsNode.getAllChildren()): node.addChild(participantsNode) return node