See note below. Just declare an int offsetArr[children.size()] here. In the for loop of your evaluate, populate this, then after the loop, just write your offset information. At this point, you'll know the max offset value, so you can size the offset (i.e. byte, short, int) appropriately based on this.