tree creation and all functions