Thanks, I'm re-writing this method now as I realized when trying to address the above comment (about number of levels) that it was really clunky. Wrote it quickly a while ago, and it worked, but on closer review it was pretty hacked together.