I've found a bug corresponding children of 'individual links'. If an individual link have a child, it is not in the REST response. The reason is that their post_name is not set to an ID but to a custom name based on the label of the item.
Changes
Changed the comparison to link children to their parents. Now the $child->menu_item_parent is compared to strval($item->ID).
I found no official documentation on wich field should be compared to menu_item_parent but the ID seems fine. There are some user contributions which use the ID.
Reason
I've found a bug corresponding children of 'individual links'. If an individual link have a child, it is not in the REST response. The reason is that their
post_name
is not set to an ID but to a custom name based on the label of the item.Changes
Changed the comparison to link children to their parents. Now the
$child->menu_item_parent
is compared tostrval($item->ID)
. I found no official documentation on wich field should be compared tomenu_item_parent
but the ID seems fine. There are some user contributions which use the ID.