in your first Post you actually add Nodes dynamically:
TreeNodeImpl nodeImpl = new TreeNodeImpl();
node.addChild(new Integer(counter), nodeImpl);
If you add in an action a TreeNodeImpl to your parent or remove a Child from a Parent node, you're done with your Task. If you use AJAX for add/remove, make sure the tree's ID is in the reRender-Property of your a4j Component.
Thank you for the reply. I am looking for implementation of context menu for tree node. In the example I am using properties file to construct the tree. But, I need to form the tree with data from Database using Hibernate. If any examples are there, Please let me know.