fixed tree bug for pattern