Added checking tree balance