rebuild binary tree