
É possível definir a camada tikz para desenhar dentro de um comando de caminho, por exemplo \node[on main layer] at (0,0) {foo};
? É um pouco tedioso colocar macros únicas em um ambiente de escopo.
Responder1
Opções behind path
e in front of path
permite sobrepor nós e linhas que são desenhadas no mesmo comando.
\documentclass[tikz,border=2mm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[thick, draw=green] (0,0) --
node[pos=0.25, behind path, fill=red!30 ]{A}
node[pos=0.75, fill=red!30 ]{A} (2,0);
\path (1,1) node[fill=blue!20] {A}
node[fill=green, behind path, inner sep=3mm] {A}
node[fill=red, inner sep=1mm, in front of path] {};
\end{tikzpicture}
\end{document}