build binary tree