Why does if-else not work correctly when it detects that a given argument is empty?
Below is my code. I want change the action argument #1 depending on whether it is empty or not. If #1 is not empty, the code works as expected. However, if #1 is empty e.g in the case of a line \foobar{}{Child3}, my code processes the code in the true part as well as in the false part of the if. The if does not work correctly. The result caused that two frames of the 2nd node were superimposed as in an attached image.
Why? And what to do to solve this problem?
\documentclass{article}
\usepackage[dvipdfmx]{graphicx} % require to color.
\usepackage{tikz}
\usetikzlibrary{trees, positioning}
\begin{document}
\begin{figure}[t]
\newcommand{\foobar}[2]{
\if\relax\detokenize{#1}\relax
node(#2){Empty!!!!!}%<EMPTY>%
\else
node(#2){#1}%<NON EMPTY>%
\fi
}
\begin{tikzpicture}[every node/.style={draw=black, thick, anchor=west}]
\node {Root}
child{\foobar{}{Child3}
% child{\foobar{child3}{Child3} % no problem, insted above line.
child{\foobar{child5}{child5}}
}; % means end of drawing
\end{tikzpicture}
\end{figure}
\end{document}
