HUE-1999 [beeswax] Update multi query separation algorithm

Updated according to the py counterpart
Updated code style