add check balance tree function