added add_node function which adds a node for a given parent