MDL-27597 fix invalid results of get_categories when shallow is false