\makeatletter

\newcount\sectionpushcounter%
\sectionpushcounter=0

\newcommand{\savesections}[1]{%
  \expandafter\let\csname \string pushedpart@#1\endcsname\part%
  \expandafter\let\csname \string pushedchapter@#1\endcsname\chapter%
  \expandafter\let\csname \string pushedsection@#1\endcsname\section%
  \expandafter\let\csname \string pushedsubsection@#1\endcsname\subsection%
  \expandafter\let\csname \string pushedsubsubsection@#1\endcsname\subsubsection%
  \expandafter\let\csname \string pushedparagraph@#1\endcsname\paragraph%
  \expandafter\let\csname \string pushedsubparagraph@#1\endcsname\subparagraph%
}%
\newcommand{\restoresections}[1]{%
  \expandafter\let\expandafter\part\csname \string pushedpart@#1\endcsname%
  \expandafter\let\expandafter\chapter\csname \string pushedchapter@#1\endcsname%
  \expandafter\let\expandafter\section\csname \string pushedsection@#1\endcsname%
  \expandafter\let\expandafter\subsection\csname \string pushedsubsection@#1\endcsname%
  \expandafter\let\expandafter\subsubsection\csname \string pushedsubsubsection@#1\endcsname%
  \expandafter\let\expandafter\paragraph\csname \string pushedparagraph@#1\endcsname%
  \expandafter\let\expandafter\subparagraph\csname \string pushedsubparagraph@#1\endcsname%
}%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%  demote chapters/sections/sub...  to be sections/subsections/subsub...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\demotesections}{%
  %in demotesections, sectionpushcounter=\the\sectionpushcounter{}%
  \ifnum\sectionpushcounter < 0%
    %case $<0$
    \restoresections{\the\sectionpushcounter}%
    \advance\sectionpushcounter by 1%
  \else%
    %case $>=0$
    \advance\sectionpushcounter by 1%
    \savesections{\the\sectionpushcounter}%
    \let\part\chapter%
    \let\chapter\section%
    \let\section\subsection%
    \let\subsection\subsubsection%
    \let\subsubsection\paragraph%
    \let\paragraph\subparagraph%
    \let\subparagraph\relax%
  \fi%
  %at end of demotesections, sectionpushcounter=\the\sectionpushcounter%
}%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%  promote sections/subsections/subsub...  to be chapters/sections/sub...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\promotesections}{%
  %in propmotesections, sectionpushcounter=\the\sectionpushcounter{}%
  \ifnum\sectionpushcounter < 1%
    %case $<1$%
    \advance\sectionpushcounter by -1%
    \savesections{\the\sectionpushcounter}%
    \let\subparagraph\paragraph%
    \let\paragraph\subsubsection%
    \let\subsubsection\subsection%
    \let\subsection\section%
    \let\section\chapter%
    \let\chapter\part%
    \let\part\relax%
  \else %
    %case $>=0$%
    \restoresections{\the\sectionpushcounter}%
    \advance\sectionpushcounter by -1%
  \fi%
  %at end of propmotesections, sectionpushcounter=\the\sectionpushcounter{}%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



\makeatother


