I have three tables:
Department :

Designation :

Department Designations :

DesignationID and ReportTo are foreign keys of table designation, which shows that a specific designation report to a specific designation. i.e. Manager(Which is designation) Report to CEO(Which is also a designation )
Now I want to generate a tree, like...

I manually enter the entries to shows above tree . i.e

Now My Problem is that, I am not able to write a function in a way that generate this tree, automatically.
In short, After fetching records from database, I want to generate tree as shown above.
Any Solution ?
NOTE: LEVEL OF TREE IS NOT FIX, THERE MAY BE UNLIMITED LEVEL OF TREE