Check children if they share children with non modules.

This helps to group children that don't share anything with outside
world into new modules. No speed improvement for current input files.
Pass and gather pointers to sets instead of copies.

This improves running times for cut set generation but not minimization.