def is_project(iterable): if iterable is None or isinstance(iterable, Undefined): return iterable return filter(lambda x: x.parent is None, iterable)