Implemented case traversing algorithm

All tests passed!