v.20.9Bug Fix

Fix Memory Limit Exceeded 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).