---
id: 65c63eb01b9563a4b8a046b6
title: Step 23
challengeType: 20
dashedName: step-23
---

# --description--

Next, define the method named `search` inside the `BinarySearchTree` class. Give the `search` method two parameters: `self` and `key`.

# --hints--

You should define a method named `search`. Remember the `pass` keyword.

```js
({ test: () => assert.match(code, /def\s+search/) });
```

The `search` method should take two parameters: `self` and `key`.

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

# --seed--

## --seed-contents--

```py

class TreeNode:

    def __init__(self, key):
        self.key = key
        self.left = None
        self.right = None


class BinarySearchTree:

    def __init__(self):
        self.root = None

    def _insert(self, node, key):
        if node is None:
            return TreeNode(key)

        if key < node.key:
            node.left = self._insert(node.left, key)
        elif key > node.key:

            node.right = self._insert(node.right, key)
        return node

    def insert(self, key):
        self.root = self._insert(self.root, key)
        
    def _search(self, node, key):
        if node is None or node.key == key:
            return node
        if key < node.key:
            return self._search(node.left, key)
        return self._search(node.right, key)
        
--fcc-editable-region--

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