added validation for add().  An error is thrown if an invalid node is added