\begin{tikzpicture}[auto,sibling distance=3.5cm, level distance=3.5cm]
  \node[] (top) { \begin{tikzpicture}
                    \node [fit={(0,0) (1,1.5)}, inner sep=0pt, thick, draw, label={$\text{s}\text{p}\text{p}$}] (rect) {};
                    \path [draw](0.1,1) -- (-0.1,1) node[left]{$A$};
                    \path [draw](0.1,0.25) -- (-0.1,0.25) node[left]{$B$};
                    \path (0.75,1) node[above]{$aa$} [draw]-- (1.1,1) node[right]{$A$};
                    \path (0.75,0.25) node[above]{$bb$} [draw]-- (1.1,0.25) node[right]{$B$};
                    \path [draw](0.1,1) -- (0.60,0.25) -- (0.75,0.25);
                    \path [draw](0.1,0.25) -- (0.60,1) -- (0.75,1);
                  \end{tikzpicture}
                }
   child { node (l) { \begin{tikzpicture}
                        \node [fit={(0,0) (1,1.5)}, inner sep=0pt, thick, draw, label={$\text{s}\text{p}$}] (rect) {};
                        \path [draw](0.1,1) -- (-0.1,1) node[left]{$A$};
                        \path [draw](0.1,0.25) -- (-0.1,0.25) node[left]{$B$};
                        \path (0.85,1) node[above]{$a$} [draw]-- (1.1,1) node[right]{$A$};
                        \path (0.85,0.25) node[above]{$b$} [draw]-- (1.1,0.25) node[right]{$B$};
                        \path [draw](0.1,1) -- (0.75,0.25) -- (0.85,0.25);
                        \path [draw](0.1,0.25) -- (0.75,1) -- (0.85,1);
                      \end{tikzpicture}
                    }
           child { node (ll) { \begin{tikzpicture}
                                 \node [fit={(0,0) (1,1.5)}, inner sep=0pt, thick, draw, label={$\text{s}$}] (rect) {};
                                 \path [draw](0.1,1) -- (-0.1,1) node[left]{$A$};
                                 \path [draw](0.1,0.25) -- (-0.1,0.25) node[left]{$B$};
                                 \path (0.85,1) node[above]{$\epsilon$} [draw]-- (1.1,1) node[right]{$A$};
                                 \path (0.85,0.25) node[above]{$\epsilon$} [draw]-- (1.1,0.25) node[right]{$B$};
                                 \path [draw](0.1,1) -- (0.75,0.25) -- (0.85,0.25);
                                 \path [draw](0.1,0.25) -- (0.75,1) -- (0.85,1);
                               \end{tikzpicture}
                             } }
           child { node (lr) { \begin{tikzpicture}
                                 \node [fit={(0,0) (1,1.5)}, inner sep=0pt, thick, draw, label={$\text{p}$}] (rect) {};
                                 \path [draw](0.1,1) -- (-0.1,1) node[left]{$A$};
                                 \path [draw](0.1,0.25) -- (-0.1,0.25) node[left]{$B$};
                                 \path (0.85,1) node[above]{$a$} [draw]-- (1.1,1) node[right]{$A$};
                                 \path (0.85,0.25) node[above]{$b$} [draw]-- (1.1,0.25) node[right]{$B$};
                                 \path [draw](0.1,0.25) -- (0.75,0.25) -- (0.85,0.25);
                                 \path [draw](0.1,1) -- (0.75,1) -- (0.85,1);
                               \end{tikzpicture}
                             } }
         }
   child { node (r) { \begin{tikzpicture}
                        \node [fit={(0,0) (1,1.5)}, inner sep=0pt, thick, draw, label={$\text{p}$}] (rect) {};
                        \path [draw](0.1,1) -- (-0.1,1) node[left]{$A$};
                        \path [draw](0.1,0.25) -- (-0.1,0.25) node[left]{$B$};
                        \path (0.85,1) node[above]{$a$} [draw]-- (1.1,1) node[right]{$A$};
                        \path (0.85,0.25) node[above]{$b$} [draw]-- (1.1,0.25) node[right]{$B$};
                        \path [draw](0.1,0.25) -- (0.75,0.25) -- (0.85,0.25);
                        \path [draw](0.1,1) -- (0.75,1) -- (0.85,1);
                      \end{tikzpicture}
                    } };
\end{tikzpicture}
