The code below solves the OPs problem. The trick is to let tikz place the nodes and then to add the labels for the nodes afterwards. To place the nodes in the requested order I use the datatool package to sort the nodes according to height before printing their labels. For the OP's two examples the output is:

As I understand the question, the labels in (2) are now OK.
The letters are the node labels whereas the numbers come from your toto counter inserted via the \SortNodes macro defined below. This macro creates a datatool database that contains the node coordinates. Making a database for the nodes seems like overkill but the point is that once they are in the database they can be easily sorted and looped over. Perhaps there is an easier/better way to do this, but this was the only way that I found to sort them.
Here is the code:
\documentclass{article}
\usepackage{datatool}
\dtlexpandnewvalue% need to expand the entries added to the database
\usepackage{tikz}
\usetikzlibrary{calc}
\newcounter{toto}
\makeatletter
\def\extractcoord#1#2#3{%from https://tex.stackexchange.com/questions/18292
\path let \p1=(#3) in \pgfextra{
\pgfmathsetmacro#1{\x{1}/\pgf@xx}
\pgfmathsetmacro#2{\y{1}/\pgf@yy}
\xdef#1{#1} \xdef#2{#2}
};
}
\newcommand\SortNodes[1]{%
% create the database and add the nodes
\DTLifdbexists{nodes}{\DTLcleardb{nodes}}{\DTLnewdb{nodes}}%
\foreach \Node in {#1} {%
\extractcoord\Nodex\Nodey\Node
\DTLnewrow{nodes}% add (x,y)-coordinates + Node label
\DTLnewdbentry{nodes}{x}{\Nodex}
\DTLnewdbentry{nodes}{y}{\Nodey}
\DTLnewdbentry{nodes}{node}{\Node}% not needed here but added anyway
}
\DTLsort*{y=descending,x}{nodes}%
\DTLforeach*{nodes}{\xx=x,\yy=y,\Node=node}{%
\node at (\xx,\yy) {\stepcounter{toto}\Node-\thetoto};% print node label
}%
}%
\makeatother
\begin{document}
\section{Ok}
\begin{tikzpicture}[sibling distance=4cm,
edge from parent/.style={draw,thick}]
\node(A){}
child {node (B){}}
child {node (C){}
child {node (D){}}
child {node (E){}}
};
\SortNodes{A,B,C,D,E}
\end{tikzpicture}
\section{Not ok}
\setcounter{toto}{0}
\begin{tikzpicture}[grow=right,sibling distance=4cm,
edge from parent/.style={draw,thick}]
\node(A){}
child {node (B){}}
child {node (C){}
child {node (D){}}
child {node (E){}}
};
\SortNodes{A,B,C,D,E}
\end{tikzpicture}
\end{document}
To find the coordinates of the nodes I use a slightly different technique than in my
related answer for the OP. The main reason for this is that I had trouble getting the database to work and, initially, I thought that the coordinates were the problem. In fact, they were the problem but for different reasons: the issue was the the entries added to the database need to be expanded so once I found the command \dtlexpandnewvalue everything worked.
This is a chance that this solution will not be compatible with the OP's use-case but I think this will be OK.