... and check that your base case is actually reached. Eg print root to make sure you don't get "stuck".

I'm wondering about the value startPosition in the recursive call. Shouldn't it...