added functions to build a submission tree from flat submission data