実行時間がO(n)である非再帰的な解決策は次のようになる：
```
def count_nodes(node)：
    count = 0
    nodes_to_search = [node].

    while len(nodes_to_search) > 0：
        count += len(nodes_to_search)

        new_nodes = [].
        for node_to_search in nodes_to_search：
            if node_to_search.left is not None：
                new_nodes.append(node_to_search.left)
            if node_to_search.right is not None：
                new_nodes.append(node_to_search.right)
        node_to_search = new_nodes
```
Eine nicht rekursive Lösung, die eine Laufzeit von O(n) hat, wäre wie folgendes:

def count_nodes(node):
    count = 0
    nodes_to_search = [node]

    while len(nodes_to_search) > 0:
        count += len(nodes_to_search)

        new_nodes = []
        for node_to_search in nodes_to_search:
            if node_to_search.left is not None:
                new_nodes.append(node_to_search.left)
            if node_to_search.right is not None:
                new_nodes.append(node_to_search.right)
        nodes_to_search = new_nodes