def IsAtom(self):
        """Returns 1 if the tree has no nonempty subtrees, 0 otherwise."""
        if self:
            if self.left or self.right:
                return 0
            else:
                return 1
        else:
            return 1
Returns 1 if the tree has no nonempty subtrees, 0 otherwise.
recipes/Python/136529_Trees_and_more_trees/recipe-136529.py