def resolve_glbs(types, hierarchy):
    """
    Given a list of types, creates and returns a set of types
    with the GLB types removed and replaced (ie added to the set)
    by their immediate non-GLB ancestors.
    """
    new_types = []
    glbs = []
    for t in types:
        if t.startswith('glb'):
            glbs.append(t)
        else:
            new_types.append(t)

    glbs = set(glbs)
    while len(glbs) > 0:
        g = glbs.pop()
        parents = (x.name for x in hierarchy[g].parents)
        for t in parents:
            if t.startswith('glb'):
                glbs.add(t)
            else:
                new_types.append(t)
    return set(new_types)