Moved max_half_tree definition