A "just for fun" implementation of a segment tree