def build_nested_schema_dict(schema_dict):
    """Accepts a dictionary in form of {SchemaRef(): schema} and returns
    dictionary in form of {schema_name: {schema_version: schema}}
    """
    result = {}
    for schema_ref, schema in schema_dict.items():
        result.setdefault(schema_ref.name, {})
        result[schema_ref.name][schema_ref.version] = schema
    return result