v.20.10Bug Fix

Fix memory limit error in extractAllGroups function

Fix the issue when some invocations of extractAllGroups function may trigger "Memory limit exceeded" error. This fixes #13383. #14889 (alexey-milovidov).