src/Datastructure/Graph/Tree/BinarySearchTree.php
public function search($value): ?BinarySearchNode {
        /** @var BinarySearchNode $node */
        $node = $this->getRoot();
        while (null !== $node) {
            if (Comparator::equals($value, $node->getValue())) {
                return $node;
            } else if (Comparator::lessThan($value, $node->getValue())) {
                $node = $node->getLeft();
            } else if (Comparator::greaterThan($value, $node->getValue())) {
                $node = $node->getRight();
            } else {
                throw new InvalidSearchComparisionException("no comparision returned true. Maybe you passed different data types (scalar, object)?");
            }
        }
        return null;
    }
public function search($value): ?BinarySearchNode {
        /** @var BinarySearchNode $node */
        $node = $this->getRoot();
        while (null !== $node) {
            if (Comparator::equals($value, $node->getValue())) {
                return $node;
            } else if (Comparator::lessThan($value, $node->getValue())) {
                $node = $node->getLeft();
            } else if (Comparator::greaterThan($value, $node->getValue())) {
                $node = $node->getRight();
            } else {
                throw new InvalidSearchComparisionException("no comparision returned true. Maybe you passed different data types (scalar, object)?");
            }
        }
        return null;
    }
public function search ( $ value ) : ? BinarySearchNode { /** @var BinarySearchNode $node */ $ node = $ this -> getRoot ( ) ; while ( null !== $ node ) { if ( Comparator :: equals ( $ value , $ node -> getValue ( ) ) ) { return $ node ; } else if ( Comparator :: lessThan ( $ value , $ node -> getValue ( ) ) ) { $ node = $ node -> getLeft ( ) ; } else if ( Comparator :: greaterThan ( $ value , $ node -> getValue ( ) ) ) { $ node = $ node -> getRight ( ) ; } else { throw new InvalidSearchComparisionException ( "no comparision returned true. Maybe you passed different data types (scalar, object)?" ) ; } } return null ; }
searches a value

@param $value
@return BinarySearchNode|null
@throws InvalidSearchComparisionException
searches a value