optimize build tree