How can I get the parent category group via the category to create multiple relation criteria?
Not 100% sure if this is correct, but this works.

Example urls:

www.mysite.com/cars/corvette/red
www.mysite.com/cars/red/corvette
...
www.mysite.com/cars/red/
www.mysite.com/cars/corvette


Here is my template:

{#
 # Check if there are multiple url segments to compare against.
 # This means we need to check against multiple relationships.
 # Ex: All Corvettes that are also Red
 #
 #}
{% if craft.request.getSegment(4)|length %}
    {% set secondaryCategory = craft.categories.slug(craft.request.getSegment(4)).first() %}
    {% set entries = craft.entries.section('mySection').relatedTo(['and', { targetElement: primaryCategory }, { targetElement: secondaryCategory }]) %}
{% else %}
    {#
     # Get all products related to the current category.
     # Ex: All Sports Cars that are related to Corvettes.
     #
     #}
    {% set entries = craft.entries.relatedTo(primaryCategory) %}
{% endif %}

...

{% if entries|length %}
    ...
{% endif %}


What i'm not sure about is both are using targetElement instead of one being sourceElement.