Nodal variational principle for excited states