Scan opt bugfix

Bug fix in ScanMerge optimization. belongs_to_set(node1, node2) was not properly checking the status of their "as_while" attribute.

Unit-test TBD.