def isAtom(self):
            """Return True if it has no subtrees, False otherwise."""
            if self:
                #ToDo: Ask node class to implement __nonzero__ to avoid
                #this test?
                iterator = iter(self.subtrees)
                try:
                    iterator.next()
                except StopIteration:
                    ret = True
                else:
                    ret = False
            else:
                ret = True
            return ret
Return True if it has no subtrees, False otherwise.
recipes/Python/201423_Trees_and_more_trees_part_II/recipe-201423.py