anchor.diff:              false -> {cont, ToReturn}
           end
       end, {UpdatedAccListResult, 0}, Children),
  -    case {result_length(Res) >= Limit, IsLast} of
  -        {true, _} ->
  +    
  +    ResultLength = result_length(Res),
  +    case ResultLength > Limit of
  +        true -> 
  +            ?critical("Listed more entries than requested in recuresive file listing of directory: ~p~nstate: ~p~noptions: ~p~n", 
  +                [file_ctx:get_logical_guid_const(FileCtx), State, ListOpts]),
  +            throw(?ERROR_INTERNAL_SERVER_ERROR);
  +        _ -> 
  +            ok
  +    end, 
  +    
  +    case {ResultLength, IsLast} of
  +        {Limit, _} ->
               ProgressMarker = case IsLast and (FinalProcessedFileCount == length(Children)) of
                   true -> done;
                   false -> more
               end,
               {ProgressMarker, Res};
  -        {false, true} ->
  +        {_, true} ->
               {done, Res};
  -        {false, false} ->
  +        {_, false} ->
               NextListOpts = maps:with([last_tree, last_name], ExtendedInfo),
               process_current_dir_in_batches(
                   UserCtx, FileCtx2, NextListOpts, State#state{limit = Limit - result_length(Res)}, Res)
  
positive.code:                 }
              };
          {false, FileCtx2} ->
              {ok, _, _, _} = list_reg_file_with_access_check(UserCtx, FileCtx2, #{size => 1}),
              #fuse_response{status = #status{code = ?OK},
                  fuse_response = #recursive_file_list{
                      inaccessible_paths = [],
  
negative.code:     {more, #list_result{}};
  process_current_dir(UserCtx, FileCtx, State) ->
      Path = build_current_dir_rel_path(State),
      % directories with path that not match given prefix, but is a prefix of this given prefix must be listed, 
      % as they are ancestor directories to files matching this given prefix
      IsAncestorDir = case Path of
          <<".">> -> true; % listing root directory
          _ -> str_utils:binary_starts_with(State#state.prefix, Path)
      end,
      case matches_prefix(Path, State) orelse IsAncestorDir of
          true ->
              {ListOpts, UpdatedState} = init_current_dir_processing(State),
              process_current_dir_in_batches(UserCtx, FileCtx, ListOpts, UpdatedState, #list_result{});
          false ->
              {done, #list_result{}}
      end.
  
  