checking tree order