Code to parse data into an 2^N-tree