Given Martin Scharrer's nice answer to this question, I am wondering if one can "undefine" nodes. That is, I'd like to know of there is a command, say, \undefine{mynode} after which Martin Scharrer's command would return undefined. Here is an illustration.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{lipsum}
\makeatletter
\newcommand{\istikznodedefined}[1]{%
\@ifundefined{pgf@sh@ns@#1}{\fbox{Sorry, I don't know about node #1!}}{%
\fbox{Sure, I node where node #1 is!}}}
\makeatother
\newcommand{\erasenode}[1]{\fbox{I can't erase node #1 yet}} % This is the command that I'd like to learn about (or create).
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\begin{document}
\istikznodedefined{a}
\lipsum[1]
\tikzmark{a}
\istikznodedefined{a}
\lipsum[2]
\erasenode{a}
Here I'd like the command \verb|\istikznodedefined{a}| to return
\begin{quote}
\fbox{Sorry, I don't know about node a!}
\end{quote}
but I don't know how to achieve this.
The real reason for asking this is that, if this worked, one could switch
annotations on and off with e.g.\ \texttt{eso-pic}.
\end{document}
