Trouble creating conditional PHP for nav menu items with children for custom Walker

I did this in my theme, so you can look at the whole code here: https://wordpress.org/themes/twenty8teen

I used the standard walker and added a filter for ‘walker_nav_menu_start_el’. Of course, I also wanted it to work for the fallback Page menu, so I cloned the standard walker and added the call to apply_filters with a slightly different filter.

/**
 * For custom menu, adding an input and label for submenus.
 */
function twenty8teen_nav_menu_start_el( $item_output, $item, $depth, $args ) {
    $classes = empty( $item->classes ) ? array() : (array) $item->classes;
    if ( $classes && in_array( 'menu-item-has-children', $classes ) ||
        in_array( 'page_item_has_children', $classes) ) {
        $item_output .= '<input type="checkbox" id="sub' . $item->ID
            . '"><label for="sub' . $item->ID . '"></label>';
    }
    return $item_output;
}

/**
 * For page menu, adding an input and label for submenus.
 */
function twenty8teen_page_menu_start_el( $item_output, $page, $depth, $args ) {
    if ( isset( $args['pages_with_children'][ $page->ID ] ) ) {
        $item_output .= '<input type="checkbox" id="sub' . $page->ID
            . '"><label for="sub' . $page->ID . '"></label>';
    }
    return $item_output;
}
add_filter( 'walker_page_menu_start_el', 'twenty8teen_page_menu_start_el', 9, 4);