moved the array_reduce to fix large search case
moved the array_reduce to fix large search case

also added some additional comments and renamed some vars to make it intuitive whats in them

Signed-off-by: Tobias Perschon <059b8b880f8441509ec8a65b50b4c6ae74ebea76@perschon.at>

nextcloud/server,nextcloud/server,nextcloud/server,nextcloud/server