def flatten(l) -> list: acc = [] for x in l: if(isinstance(x, list)): acc += flatten(x) elif(x is not None): acc.append(x) return acc