I am trying to solve How to rotate a composition of Tikz nodes correctly, without rotating the text of their labels?; and I found tikz pgf - Problem with "append after command" and "insert path".
This gave me the following idea - define a style, such that it simply places another node on top of the "current" one, with a colored background so the new node obscures the old, and with the same contents of the "current" node, but rotated. This is how far I got:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\usetikzlibrary{fit}
% https://tex.stackexchange.com/questions/55722/problem-with-append-after-command-and-insert-path
\makeatletter
\def\mymacro{
\begin{scope}
% { % MUST have this group! or scope!
\setbox\tikz@figbox=\box\pgfutil@voidb@x
\node at (\tikzlastnode) [fill=yellow] {\rotatebox{180}{YY}}; %
% }
\end{scope}
}
\makeatother
\tikzstyle{drc} = [draw, rectangle, line width=1pt, align=center,
append after command={\pgfextra{\mymacro}},
% insert path={\pgfextra{\mymacro}}, % no \tikzlastnode
]
\begin{document}
\begin{tikzpicture}[line width=3mm]
\node[drc] at (0,0) {\ \ A};
\node[drc] at (1,1) {B\ \ };
\end{tikzpicture}
\end{document}
This is the output:

The problems/questions are:
- The appended node is behind the original node, so its fill cannot obscure the original node - any way to get it in front of the original node?
- I'm just having the letters
YYfor a test - but I'd rather "extract" the text of\tikzlastnode; however, it seems that\tikzlastnodeis basically just the name of the last node, not an "object reference". In any case, is there a way to extract and reuse the text of\tikzlastnode?

