[Update] build tree function