/// <summary>
        /// Returns the first item of the <paramref name="query"/> as the generic Page type and null if no items were returned.
        /// </summary>
        /// <param name="query">The current DocumentQuery</param>
        /// <param name="token">Optional cancellation token</param>
        /// <returns></returns>
        public static async Task <TDocument?> FirstOrDefaultAsync <TDocument>(this DocumentQuery <TDocument> query, CancellationToken token = default)
            where TDocument : TreeNode, new()
        {
            var result = await query.GetEnumerableTypedResultAsync(cancellationToken : token);

            return(result?.FirstOrDefault());
        }
        /// <summary>
        /// Converts the <paramref name="query"/> to a <see cref="List{TDocument}"/> of the generic Page type
        /// </summary>
        /// <param name="query">The current DocumentQuery</param>
        /// <param name="projection">Mapping function from <typeparamref name="TDocument" /> to <typeparamref name="TReturn" /></param>
        /// <param name="token">Optional cancellation token</param>
        /// <returns></returns>
        public static async Task <IList <TReturn> > ToListAsync <TDocument, TReturn>(
            this DocumentQuery <TDocument> query,
            Func <TDocument, TReturn> projection,
            CancellationToken token = default)
            where TDocument : TreeNode, new()
        {
            var result = await query.GetEnumerableTypedResultAsync(cancellationToken : token);

            return(result.Select(projection).ToList());
        }
        /// <summary>
        /// Returns the first item of the <paramref name="query"/> as the generic Page type and null if no items were returned.
        /// </summary>
        /// <param name="query">The current DocumentQuery</param>
        /// <param name="projection">Mapping function from <typeparamref name="TDocument" /> to <typeparamref name="TReturn" /></param>
        /// <param name="token">Optional cancellation token</param>
        /// <returns></returns>
        public static async Task <TReturn?> FirstOrDefaultAsync <TDocument, TReturn>(
            this DocumentQuery <TDocument> query,
            Func <TDocument, TReturn> projection,
            CancellationToken token = default)
            where TDocument : TreeNode, new()
            where TReturn : class
        {
            var result = await query.GetEnumerableTypedResultAsync(cancellationToken : token);

            return(result?.Select(projection).FirstOrDefault());
        }