def _is_subexpansion_optional(query_metadata, parent_location, child_location):
    """Return True if child_location is the root of an optional subexpansion."""
    child_optional_depth = query_metadata.get_location_info(child_location).optional_scopes_depth
    parent_optional_depth = query_metadata.get_location_info(parent_location).optional_scopes_depth
    return child_optional_depth > parent_optional_depth