remove superfluous level between terminals and preterminals