class NodeMessage<M> {
        /** */
        boolean nodeFailed;

        /** */
        M msg;

        /**
         * @param msg Message.
         */
        NodeMessage(M msg) {
            this.msg = msg;
        }

        /**
         * @return Message or {@code null} if node failed.
         */
        @Nullable public M message() {
            return msg;
        }

        /**
         * @return {@code True} if node result was not set before.
         */
        boolean onNodeFailed() {<FILL_FUNCTION_BODY>}

        /**
         * @param msg Received message.
         * @return {@code True} if node result was not set before.
         */
        boolean set(M msg) {
            assert msg != null;

            if (this.msg != null)
                return false;

            this.msg = msg;

            return !nodeFailed;
        }

        /** {@inheritDoc} */
        @Override public String toString() {
            return S.toString(NodeMessage.class, this);
        }
    }

            if (nodeFailed || msg != null)
                return false;

            nodeFailed = true;

            return true;
        
<no_super_class>