Organizations restructure all the time. Sometimes they add layers of management especially when the company is growing and that just means there is too much work for the director to directly supervise everyone.
To evaluate if this is a problem for you then you need to think about the answers to these questions:
Have there been any performance issues brought to my attention. If so then yes you have likely been downgraded.
Has my pay been affected? If yes, then you have been downgraded.
How does my report status compare to others in the organization who are doing equivalent work? If you are the only person reporting to this mentor and all the other devs report to the director still, then there could (note could not must) be a problem. If the group you are in does something specialized like say Data Science as opposed to a general development, then probably not, otherwise, this is a key signal there may be a problem.
Is there an obvious organizational need for a new group? If so, then no you are not demoted. They are simply splitting up responsibilities above you.
Is the organization growing rapidly? Then it is likely just that more layers need to be put into be able to effectively manage. This can be a plus or a minus, more layers and more people generally means more opportunity to move up in the organization but it often comes with more bureaucracy as well.
Is your new boss well respected in the organization? If yes then you likely don't have a problem, If no then you and he have been shunted off to get you out of the way and it could be a very big red flag.
Is it always best to report directly to top management - not likely unless you are very senior. As long as you are organizationally at the same level as your peers, there is not likely to be a problem due to organizational position. Junior people are expected to be at the bottom of the hierarchy. And nothing stops you from impressing the top person even if you don't directly report to him or her. Significant accomplishments that are known in the organization count for far more than who you report to (unless the person you report to is someone who has no organizational influence).