Add parent child case selection graph cycle detection

Addresses: http://manage.dimagi.com/default.asp?136721

Adds a build error if there are cycles in the parent child selection graph. I was also inspired by the dev summit to write a test :stuck_out_tongue_winking_eye:
I don't think `_has_cycles` is specific enough a name for this method. I think `has_parent_child_selection_cycle` or something similarly verbose is better.