fixed problem with assigning parent to nodes