Page naming when there is a sub-category only sometimes.

What do u mean by:

Page naming

?? If you are after a way to implement this situation, then here you go:

You have 2 options:

1st Option

Use

'hierarchical'                  => false

while registering your apples post type, using register_post_type. Then, you will have the option to put apples posts, as parents and children, using the post edit page.

2nd Option:

Use

function add_apples_cat_taxonomy(){
    register_taxonomy(
        'apples_category',
        'apples',
        array(
            'label' => __( 'Apples category' ),
            'rewrite' => array( 'slug' => 'apples_cat' ),
            'hierarchical' => true
        )
    );
}

add_action( 'init', 'add_apples_cat_taxonomy' );

to add an post_type dependent taxonomy named apples_category, and use it to expand the desired hirearchy.