/// <summary>
        /// Context-preserving variant of <see cref="FlowOperations.Grouped{TIn,TOut,TMat}"/>
        /// </summary>
        public static FlowWithContext <TCtx, TIn, TCtx, TOut, TMat> WhereNot <TCtx, TIn, TOut, TMat>(
            this FlowWithContext <TCtx, TIn, TCtx, TOut, TMat> flow, Func <TOut, bool> predicate)
        {
            var stage = new Where <(TOut, TCtx)>(x => !predicate(x.Item1));

            return(flow.Via(Flow.FromGraph(stage)));
        }
        /// <summary>
        /// Context-preserving variant of <see cref="FlowOperations.Select{T,TIn,TOut,TMat}"/>
        /// </summary>
        public static FlowWithContext <TCtx, TIn, TCtx, TOut2, TMat> Select <TCtx, TIn, TOut, TOut2, TMat>(
            this FlowWithContext <TCtx, TIn, TCtx, TOut, TMat> flow, Func <TOut, TOut2> fn)
        {
            var stage = new Select <(TOut, TCtx), (TOut2, TCtx)>(x => (fn(x.Item1), x.Item2));

            return(flow.Via(Flow.FromGraph(stage)));
        }
        /// <summary>
        /// Context-preserving variant of <see cref="FlowOperations.SelectAsync{T,TIn,TOut,TMat}"/>
        /// </summary>
        public static FlowWithContext <TCtx, TIn, TCtx, TOut2, TMat> SelectAsync <TCtx, TIn, TOut, TOut2, TMat>(
            this FlowWithContext <TCtx, TIn, TCtx, TOut, TMat> flow, int parallelism, Func <TOut, Task <TOut2> > fn)
        {
            var stage = new SelectAsync <(TOut, TCtx), (TOut2, TCtx)>(parallelism,
                                                                      async x => (await fn(x.Item1), x.Item2));

            return(flow.Via(Flow.FromGraph(stage)));
        }
        /// <summary>
        /// Apply the given function to each context element (leaving the data elements unchanged).
        /// </summary>
        public static FlowWithContext <TCtx, TIn, TCtx2, TOut, TMat> SelectContext <TCtx, TIn, TCtx2, TOut, TMat>(
            this FlowWithContext <TCtx, TIn, TCtx, TOut, TMat> flow, Func <TCtx, TCtx2> mapContext)
        {
            var stage = new Select <(TOut, TCtx), (TOut, TCtx2)>(x =>
                                                                 (x.Item1, mapContext(x.Item2)));

            return(flow.Via(Flow.FromGraph(stage)));
        }
        /// <summary>
        /// Context-preserving variant of <see cref="FlowOperations.Collect{T,TIn,TOut,TMat}"/>
        /// </summary>
        public static FlowWithContext <TCtx, TIn, TCtx, TOut2, TMat> Collect <TCtx, TIn, TOut, TOut2, TMat>(
            this FlowWithContext <TCtx, TIn, TCtx, TOut, TMat> flow, Func <TOut, TOut2> fn) where TOut2 : class
        {
            var stage = new Collect <(TOut, TCtx), (TOut2, TCtx)>(func: x =>
            {
                var result = fn(x.Item1);
                return(ReferenceEquals(result, null) ? default((TOut2, TCtx)) : (result, x.Item2));
            });

            return(flow.Via(Flow.FromGraph(stage)));
        }
        /// <summary>
        /// Context-preserving variant of <see cref="FlowOperations.StatefulSelectMany{T,TIn,TOut,TMat}"/>.
        /// </summary>
        public static FlowWithContext <TCtx, TIn, TCtx, TOut2, TMat> StatefulSelectConcat <TCtx, TIn, TOut, TOut2, TMat>(
            this FlowWithContext <TCtx, TIn, TCtx, TOut, TMat> flow, Func <Func <TOut, IEnumerable <TOut2> > > fn)
        {
            var stage = new StatefulSelectMany <(TOut, TCtx), (TOut2, TCtx)>(() =>
            {
                var fun = fn();
                return(itemWithContext =>
                {
                    var items = fun(itemWithContext.Item1);
                    return items.Select(i => (i, itemWithContext.Item2));
                });
            });

            return(flow.Via(Flow.FromGraph(stage)));
        }