Optimize the code: do not add the projection node if not needed