Update flatten algorithm to not generate nodes containing only @id.