Fixed bad parsing of parent_id

Previous implementation would eroneously set parent_id to 0 or 1,
whereas it should be set to 0 or the integer ID of the parent.