parser: Contract recursive loops

* The contract() function should not only eliminate intermediate nodes,
  but nodes of the same type as their parents as well (since the syntax
  definition is too complex for this to happen outside of simple loops
  through recursion)

Signed-off-by: Max Reitz <xanclic@niwohlos.org>