@Override
    public V put(String key, V value) {
        // Keys can not be null
        if (key == null) {
            throw new NullPointerException("Key can not be null");
        }

        // Empty keys are stored in the root
        if (key.equals("")) {
            PatriciaNode<V> node = new PatriciaNode<>(key, value, -1);
            node.setValue(value);
            root.setRight(node);
            entries++;
            return value;
        }

        // Find nearest node
        PatriciaNode<V> nearest = findNearestNode(key);

        // Key already exist, replace value and return
        if (key.equals(nearest.getKey())) {
            nearest.setValue(value);
            return value;
        }

        // Find differing bit and create new node to insert
        int bit = findFirstDifferingBit(key, nearest.getKey());
        PatriciaNode<V> node = new PatriciaNode<>(key, value, bit);

        // Insert new node
        insertNode(node);

        entries++;

        return value;
    }
@ Override public V put ( String key , V value ) { if ( key == null ) { throw new NullPointerException ( "Key can not be null" ) ; } if ( key . equals ( "" ) ) { PatriciaNode < V > node = new PatriciaNode < > ( key , value , - 1 ) ; node . setValue ( value ) ; root . setRight ( node ) ; entries ++ ; return value ; } PatriciaNode < V > nearest = findNearestNode ( key ) ; if ( key . equals ( nearest . getKey ( ) ) ) { nearest . setValue ( value ) ; return value ; } int bit = findFirstDifferingBit ( key , nearest . getKey ( ) ) ; PatriciaNode < V > node = new PatriciaNode < > ( key , value , bit ) ; insertNode ( node ) ; entries ++ ; return value ; }
Puts value into trie identifiable by key into this trie (key should be non-null)

@param key  key to associate with value
@param value  value be inserted
@return value inserted
@throws NullPointerException in case key is null