def METHOD_NAME(Lhash, degree, trace_hash):
    # objects for the factors
    instances = []
    if "," in Lhash:
        for factor_Lhash in set(Lhash.split(",")):
            elt = db.lfunc_lfunctions.lucky({'Lhash': factor_Lhash},
                                            ['trace_hash', 'degree'])
            # names_and_urls will remove duplicates
            instances.extend(
                get_instances_by_Lhash_and_trace_hash(factor_Lhash,
                    elt['degree'], elt.get('trace_hash', None)))
    # try to get factors as EC, this only arises for G2C
    for elt in db.lfunc_instances.search({'Lhash': Lhash, 'type': 'ECQP'},
                                         'url'):
        if '|' in elt:
            for url in elt.split('|'):
                url = url.rstrip('/')
                # Lhash = trace_hash
                instances.extend(get_instances_by_trace_hash(2, db.lfunc_instances.lucky({'url': url}, 'Lhash')))
    # or we need to use the trace_hash to find other factorizations
    if str(trace_hash) == Lhash:
        for elt in db.lfunc_lfunctions.search(
                {'trace_hash': trace_hash, 'degree': degree}, 'Lhash'):
            instances.extend(METHOD_NAME(elt, None, None))
    return instances