title: How would I fix this? builtins.AttributeError: 'NoneType' object has no attribute '_helper'
body: <p>I keep on getting this error, and I don't know how I'd go about correcting it.
  I'm trying to implement method count_less in class BST. And I'm writing a helper method in class _BSTNode and calling the helper within count_less using indirect recursion.</p>
  
  <p>Thank you.</p>
  
  <pre><code>class BST:
      """A Binary Search Tree."""
  
      def __init__(self: 'BST', container: list =[]) -&gt; None:
          """
          Initialize this BST by inserting the items from container (default [])
          one by one, in the order given.
          """
          # Initialize empty tree.
          self.root = None
          # Insert every item from container.
          for item in container:
              self.insert(item)
  
      def __str__(self: 'BST') -&gt; str:
          """
          Return a "sideways" representation of the values in this BST, with
          right subtrees above nodes above left subtrees and each value preceded
          by a number of TAB characters equal to its depth.
          """
          return self.root._str("") if self.root else ""
  
      def insert(self: 'BST', item: object) -&gt; None:
          """
          Insert item into this BST.
          """
          if self.root:
              self.root.insert(item)
          else:
              self.root = _BSTNode(item)
  
      def count_less(self: 'BST', item: object) -&gt; int:
          """
          Return the number of items in this BST that are strictly less tham
          item.
          """
  
          return self.root._helper(self.root, item)
  
  
  
  class _BSTNode:
      """A node in a BST."""
  
      def __init__(self: '_BSTNode', item: object, 
                   left: '_BSTNode' =None, right: '_BSTNode' =None) -&gt; None:
          """
          Initialize this node to store item and have children left and right.
          """
          self.item, self.left, self.right = item, left, right
  
      def _str(self: '_BSTNode', indent: str) -&gt; str:
          """
          Return a "sideways" representation of the values in the BST rooted at
          this node, with right subtrees above nodes above left subtrees and each
          value preceded by a number of TAB characters equal to its depth, plus
          indent.
          """
          return ((self.right._str(indent + '\t') if self.right else '') +
                  indent + str(self.item) + '\n' +
                  (self.left._str(indent + '\t') if self.left else ''))
  
      def insert(self: '_BSTNode', item: object) -&gt; None:
          """
          Insert item into the BST rooted at this node.
          """
          if item &lt; self.item:
              if self.left:
                  self.left.insert(item)
              else:
                  self.left = _BSTNode(item)
          elif item &gt; self.item:
              if self.right:
                  self.right.insert(item)
              else:
                  self.right = _BSTNode(item)
          # else:  # item == self.item
          #     pass  # nothing to do: item is already in the tree
  
      def _helper(self, item):
          count = 0
          if not self.item:
              return 0
          if self.item &lt; item:
              count += 1
          count +=  count_less(self.left, item)
          count += count_less(self.right, item)
          return count
  </code></pre>