def get_forward_entities(entityset, entity_id):
    ids = []
    entity_id_pipe = [entity_id]
    while len(entity_id_pipe):
        entity_id = entity_id_pipe[0]
        entity_id_pipe = entity_id_pipe[1:]
        ids.append(entity_id)
        for (child_id, _) in entityset.get_forward_entities(entity_id):
            entity_id_pipe.append(child_id)
    return ids
def get_forward_entities(entityset, entity_id):
    ids = []
    entity_id_pipe = [entity_id]
    while len(entity_id_pipe):
        entity_id = entity_id_pipe[0]
        entity_id_pipe = entity_id_pipe[1:]
        ids.append(entity_id)
        for (child_id, _) in entityset.get_forward_entities(entity_id):
            entity_id_pipe.append(child_id)
    return ids