change map to binary tree