---
id: 65c4f195de7e2ad5932be717
title: Step 9
challengeType: 20
dashedName: step-9
---

# --description--

Next, you need to define a mechanism to insert nodes in the tree. For that, you need to define an `_insert` method, which is a helper function and would be used by the actual `insert` method later on. 

This method is recursive, meaning it calls itself to traverse the tree until the appropriate location for the new node is found.

Define an `_insert` method with the parameters `self`, `node` and `key`.

# --hints--

You should define an `_insert` method within the `BinarySearchTree` class. Remember to use `pass`.

```js
({ test: () => assert.match(code, /def\s+_insert\s*\([^(]*\)\s*:/m) })
```

Your `_insert` method should take three parameters: `self`, `node` and `key`.

```js
({ test: () => assert.match(code, /def\s+_insert\s*\(\s*self\s*,\s*node\s*,\s*key\s*\)\s*:/m) })
```

# --seed--

## --seed-contents--

```py
class TreeNode:
    def __init__(self, key):
        self.key = key
        self.left = None
        self.right = None
--fcc-editable-region--
class BinarySearchTree:
    def __init__(self):
        self.root = None

--fcc-editable-region--
```
