sample denormalization and building sample tree hierarchy