# How to highlight some portion of binary tree?

I want to draw complete binary tree with some portion highlighted. I am able to draw the complete binary tree, but not able to highlight the specified portion.

I want to draw the digram given below:

Till now I'm able to do this much:

\documentclass[border=2pt]{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
for tree={l+=0.07cm} % increase level distance
[1
[2[4][5]]
[3[6][7]]
]
\end{forest}
\end{document}


I think, in theory, that this should be possible by adding

tikz={\node[draw,circle,red,fit=()(!1)(!2)}


to the root of the node that you want to circle. Here () refers to the node and (!1) and (!2) its children. Unfortunately, this doesn't quite work because it gives:

So, in practice, it looks better with a little extra tweaking:

See section 2.3 of the manual for more details.

Here is the full code:

\documentclass[border=4pt]{standalone}
\usepackage{forest}
\begin{document}

\begin{forest}
for tree={l+=0.08cm} % increase level distance
[1
[2,tikz={\node[draw,circle,red,fit=()(!1),inner sep=0mm,xshift=1mm]{};}
[4][5]
]
[3
[6][7]
]
]
\end{forest}

\end{document}


Another option, which might be preferable, is to use

tikz={\node[draw,circle,red,fit=()(!1)(!2),inner sep=0mm]{};}


giving

Here is another solution to use the istgame package. Since the istgame environment is (almost) the same as the tikzpicture environment, you can use any TikZ macros in the istgame environment.

\documentclass{standalone}

\usepackage{istgame}
\usepackage{makecell}

\begin{document}

\begin{istgame}
% tree (istgame macros)
\xtdistance{15mm}{30mm}
\istroot(1){1} \istb \istb \endist
\xtdistance{15mm}{15mm}
\istroot(2)(1-1)<180>{2}
\istb*{}{4} \istb*{}{5} \endist
\istroot(3)(1-2)<0>{3}
\istb*{}{6} \istb*{}{7} \endist
\xtSubgameOval(2){(2-1)(2-2)}[circle,solid,red,inner sep=10pt]