def METHOD_NAME(self, frame_children, form=None, should_add_last_selection_datum=True):
    def should_include(child, add_selection_datum):
        if not isinstance(child, WorkflowDatumMeta):
            return False
        if child.requires_selection and add_selection_datum:
            return True
        if form:
            return child.id in (form.function_datum_endpoints or [])
        return False
    return [
        child.id for child in frame_children
        if should_include(child, should_add_last_selection_datum or child != frame_children[-1])
    ]