Better optimize setting of parent_id