src/Common/Abstracts/AbstractLinkedList.php
public function getNodeByKey($key): ?Node {
        if (!$this->containsKey($key)) {
            return null;
        }
        $head = $this->getHead();
        while ($head !== null) {
            if (Comparator::equals($head->getKey(), $key)) {
                return $head;
            }
            $head = $head->getNext();
        }
        return null;
    }
public function getNodeByKey($key): ?Node {
        if (!$this->containsKey($key)) {
            return null;
        }
        $head = $this->getHead();
        while ($head !== null) {
            if (Comparator::equals($head->getKey(), $key)) {
                return $head;
            }
            $head = $head->getNext();
        }
        return null;
    }
public function getNodeByKey ( $ key ) : ? Node { if ( ! $ this -> containsKey ( $ key ) ) { return null ; } $ head = $ this -> getHead ( ) ; while ( $ head !== null ) { if ( Comparator :: equals ( $ head -> getKey ( ) , $ key ) ) { return $ head ; } $ head = $ head -> getNext ( ) ; } return null ; }
returns a node by a given key

@param $key
@return \doganoo\PHPAlgorithms\Datastructure\Lists\Node|null
returns a node by a given key