separates aggregationTree generation algorithm in seperate function