Look at the approach I explained here - Binary partitioning - #3 by aggarg
Would it work for you?
Thanks.