Here is my current code for the picture:
\documentclass[a4paper,12pt]{article}
\usepackage{tikz}
\usetikzlibrary{trees}
\begin{document}
\resizebox{.5\textwidth}{!}{
\tikzset{level 1/.style={level distance=0.7cm, sibling distance=3cm}}
\tikzset{level 2/.style={level distance=0.7cm, sibling distance=6cm}}
\tikzset{bag/.style={text centered,yshift=-0.2cm}}
\begin{tikzpicture}[grow=down, -stealth]
\node[bag]{$S_0{:}(B,true,0)$}
child{ edge from parent node[right]{$\_ DS$}; \node[bag]{$S_1{:}(R_{good})$}
child{ edge from parent node[right]{and}; \node[bag]{$S_2{:}(and)$}
child[missing]
child{ edge from parent node[right=0.1cm]{$[else]$}; \node[bag]{$S_3{:}(A_1)$}
}
child{ edge from parent node[right=0.9cm]{$[if]$}; \node[bag]{$S_4{:}(R_{good})$}
}
}
};
\end{tikzpicture}}
\end{document}
the result is
however, I want to change the line from s2 to s4 to -|, which I have described in the image using the red line, I tried to use the code child{ edge from parent[-|]node[right=0.9cm]{$[if]$}; \node[bag]{$S_4{:}(R_{good})$}; \node[bag]{$S_3{:}(A_1)$} but it doesn't work would someone help me?
