def get_parents(key, parents):
    """Get parents for a particular key through parents dict"""
    r = [key]
    while True:
        this_one = r[-1]
        if this_one == 'COM':
            return r
        r.append(parents[this_one])