i started with nested for-each loop and said that every time i will check whether there is any child element of that .and if child element is there i will go for the next loop .but he restrict me saying that the hierarchy is not limited .try it with recursion.then i started using recursion but i do not know how to pass the element when i know that there is a child element of any element because jav