I want to write Recursive method for component nodes which have "container"
I want a list of components in a page while using recursion method in java

parent 1, child 2 , grandchild 3 and there might be another child will also come there
As shown in picture there are some "container" nodes having components inside. For every container node it should get node of the component and add to a java map of values title and heading of the node
NOTE : It should maintain the page order of components
Any reference please?