Define a Prolog predicate flatten(List, FlattenedList) that asserts List is any nested list of atoms and FlattenedList is the same list with the nesting removed. The atom  should also be removed. Your predicate should only produce one answer. You may use the built-in predicates not, ! and append. Do not use a helper predicate.
?- flatten([a, [[b,c],d], [[e]], [f]], X).
X = [a,b,c,d,e,f] ;
?- flatten([a,[], [[c,d],e]], X).
X = [a,c,d,e] ;