You'd want to say `if parent_field in doc`, because otherwise, you get the wrong answer if the parent ID is 0.