public function search(array $sample) : ?BinaryNode
    {
        $current = $this->root;

        while ($current) {
            if ($current instanceof Decision) {
                $value = $current->value();

                if (is_string($value)) {
                    if ($sample[$current->column()] === $value) {
                        $current = $current->left();
                    } else {
                        $current = $current->right();
                    }
                } else {
                    if ($sample[$current->column()] < $value) {
                        $current = $current->left();
                    } else {
                        $current = $current->right();
                    }
                }

                continue 1;
            }

            if ($current instanceof Leaf) {
                break 1;
            }
        }

        return $current;
    }
public function search(array $sample) : ?BinaryNode
    {
        $current = $this->root;

        while ($current) {
            if ($current instanceof Decision) {
                $value = $current->value();

                if (is_string($value)) {
                    if ($sample[$current->column()] === $value) {
                        $current = $current->left();
                    } else {
                        $current = $current->right();
                    }
                } else {
                    if ($sample[$current->column()] < $value) {
                        $current = $current->left();
                    } else {
                        $current = $current->right();
                    }
                }

                continue 1;
            }

            if ($current instanceof Leaf) {
                break 1;
            }
        }

        return $current;
    }
public function search ( array $ sample ) : ? BinaryNode { $ current = $ this -> root ; while ( $ current ) { if ( $ current instanceof Decision ) { $ value = $ current -> value ( ) ; if ( is_string ( $ value ) ) { if ( $ sample [ $ current -> column ( ) ] === $ value ) { $ current = $ current -> left ( ) ; } else { $ current = $ current -> right ( ) ; } } else { if ( $ sample [ $ current -> column ( ) ] < $ value ) { $ current = $ current -> left ( ) ; } else { $ current = $ current -> right ( ) ; } } continue 1 ; } if ( $ current instanceof Leaf ) { break 1 ; } } return $ current ; }
Search the tree for a leaf node.

@param array $sample
@return \Rubix\ML\Graph\Nodes\BinaryNode|null
Search the tree for a leaf node .