private Node<K, V> putKeyNode( G group, K key, V value ) {
        if( key == null || value == null ) { throw new NullPointerException(); }

        //Find group.
        GroupNode<K, V> groupNode = getGroupNodeInstance( group );

        //Find place in bucket table.
        final Node<K, V>[] buckets = mKeyBuckets;
        final int          hash    = rehash( key.hashCode() );
        final int          idx     = hash & (buckets.length - 1);

        Node<K, V> parent  = null;
        Node<K, V> ret     = buckets[idx];
        Node<K, V> newNode = null;

        while( true ) {
            if( ret == null ) {
                newNode = new Node<K, V>( groupNode, key, value, hash );

                mModCount++;
                mKeyCount++;
                newNode.mNext = buckets[idx];
                buckets[idx] = newNode;

                if( mKeyCount >= mKeyThreshold ) { resizeKeys( buckets.length * 2 ); }

                break;

            } else if( hash == ret.mHash && key == ret.mKey || key.equals( ret.mKey ) ) {
                if( ret.mGroup == groupNode && ret.mValue == value ) { return ret; }

                newNode = new Node<K, V>( groupNode, key, value, hash );

                removeNodeAll( ret );
                removeNodeGroup( ret.mGroup, ret );
                mModCount++;

                if( parent == null ) {
                    buckets[idx] = ret.mNext;
                } else {
                    parent.mNext = ret.mNext;
                }

                newNode.mNext = buckets[idx];
                buckets[idx] = newNode;
                break;
            }

            parent = ret;
            ret = ret.mNext;
        }

        //Insert node into group.
        Node<K, V> node = groupNode.mRoot;

        if( node == null ) {
            insertNodeGroup( groupNode, newNode, null, LEFT );

        } else {
            if( mValueComparator != null ) {
                Comparator<? super V> comp = mValueComparator;

                while( true ) {
                    int c = comp.compare( value, node.mValue );

                    if( c < 0 ) {
                        if( node.mGroupLeft == null ) {
                            insertNodeGroup( groupNode, newNode, node, LEFT );
                            break;
                        } else {
                            node = node.mGroupLeft;
                        }

                    } else if( c > 0 ) {
                        if( node.mGroupRight == null ) {
                            insertNodeGroup( groupNode, newNode, node, RIGHT );
                            break;
                        } else {
                            node = node.mGroupRight;
                        }

                    } else {
                        removeNodeCompletely( node, false );
                        node = groupNode.mRoot;

                        if( node == null ) {
                            insertNodeGroup( groupNode, newNode, null, LEFT );
                            break;
                        }
                    }
                }

            } else {
                Comparable<? super V> comp = (Comparable<? super V>)value;

                while( true ) {
                    int c = comp.compareTo( node.mValue );

                    if( c < 0 ) {
                        if( node.mGroupLeft == null ) {
                            insertNodeGroup( groupNode, newNode, node, LEFT );
                            break;
                        } else {
                            node = node.mGroupLeft;
                        }

                    } else if( c > 0 ) {
                        if( node.mGroupRight == null ) {
                            insertNodeGroup( groupNode, newNode, node, RIGHT );
                            break;
                        } else {
                            node = node.mGroupRight;
                        }
                    } else {
                        removeNodeCompletely( node, false );
                        node = groupNode.mRoot;

                        if( node == null ) {
                            insertNodeGroup( groupNode, newNode, null, LEFT );
                            break;
                        }
                    }
                }
            }
        }

        //Insert node into all.
        node = mAllRoot;

        if( node == null ) {
            insertNodeAll( newNode, null, LEFT );
            return ret;
        }

        if( mValueComparator != null ) {
            if( mGroupComparator != null ) {
                Comparator<? super V> comp      = mValueComparator;
                Comparator<? super G> groupComp = mGroupComparator;

                while( true ) {
                    int c = comp.compare( value, node.mValue );

                    if( c < 0 ) {
                        if( node.mAllLeft == null ) {
                            insertNodeAll( newNode, node, LEFT );
                            return ret;
                        } else {
                            node = node.mAllLeft;
                        }

                    } else if( c > 0 ) {
                        if( node.mAllRight == null ) {
                            insertNodeAll( newNode, node, RIGHT );
                            return ret;
                        } else {
                            node = node.mAllRight;
                        }
                    } else {
                        G nodeGroup = (G)node.mGroup.mGroup;

                        if( group == null ) {
                            if( nodeGroup == null ) { return ret; }

                            c = -1;
                        } else if( nodeGroup == null ) {
                            c = 1;
                        } else {
                            c = groupComp.compare( group, nodeGroup );
                        }


                        if( c < 0 ) {
                            if( node.mAllLeft == null ) {
                                insertNodeAll( newNode, node, LEFT );
                                return ret;
                            } else {
                                node = node.mAllLeft;
                            }

                        } else if( c > 0 ) {
                            if( node.mAllRight == null ) {
                                insertNodeAll( newNode, node, RIGHT );
                                return ret;
                            } else {
                                node = node.mAllRight;
                            }

                        } else {
                            removeNodeCompletely( node, true );
                            node = mAllRoot;

                            if( node == null ) {
                                insertNodeAll( newNode, null, LEFT );
                                return ret;
                            }
                        }
                    }
                }

            } else {
                Comparator<? super V> comp      = mValueComparator;
                Comparable<? super G> groupComp = (Comparable<? super G>)group;

                while( true ) {
                    int c = comp.compare( value, node.mValue );

                    if( c < 0 ) {
                        if( node.mAllLeft == null ) {
                            insertNodeAll( newNode, node, LEFT );
                            return ret;
                        } else {
                            node = node.mAllLeft;
                        }

                    } else if( c > 0 ) {
                        if( node.mAllRight == null ) {
                            insertNodeAll( newNode, node, RIGHT );
                            return ret;
                        } else {
                            node = node.mAllRight;
                        }
                    } else {
                        G nodeGroup = (G)node.mGroup.mGroup;

                        if( group == null ) {
                            if( nodeGroup == null ) { return ret; }

                            c = -1;
                        } else if( nodeGroup == null ) {
                            c = 1;
                        } else {
                            c = groupComp.compareTo( nodeGroup );
                        }


                        if( c < 0 ) {
                            if( node.mAllLeft == null ) {
                                insertNodeAll( newNode, node, LEFT );
                                return ret;
                            } else {
                                node = node.mAllLeft;
                            }

                        } else if( c > 0 ) {
                            if( node.mAllRight == null ) {
                                insertNodeAll( newNode, node, RIGHT );
                                return ret;
                            } else {
                                node = node.mAllRight;
                            }
                        } else {
                            removeNodeCompletely( node, true );
                            node = mAllRoot;

                            if( node == null ) {
                                insertNodeAll( newNode, null, LEFT );
                                return ret;
                            }
                        }
                    }
                }
            }
        } else {
            if( mGroupComparator != null ) {
                Comparable<? super V> comp      = (Comparable<? super V>)value;
                Comparator<? super G> groupComp = mGroupComparator;

                while( true ) {
                    int c = comp.compareTo( node.mValue );

                    if( c < 0 ) {
                        if( node.mAllLeft == null ) {
                            insertNodeAll( newNode, node, LEFT );
                            return ret;
                        } else {
                            node = node.mAllLeft;
                        }

                    } else if( c > 0 ) {
                        if( node.mAllRight == null ) {
                            insertNodeAll( newNode, node, RIGHT );
                            return ret;
                        } else {
                            node = node.mAllRight;
                        }
                    } else {
                        G nodeGroup = (G)node.mGroup.mGroup;

                        if( group == null ) {
                            if( nodeGroup == null ) { return ret; }

                            c = -1;
                        } else if( nodeGroup == null ) {
                            c = 1;
                        } else {
                            c = groupComp.compare( group, nodeGroup );
                        }


                        if( c < 0 ) {
                            if( node.mAllLeft == null ) {
                                insertNodeAll( newNode, node, LEFT );
                                return ret;
                            } else {
                                node = node.mAllLeft;
                            }

                        } else if( c > 0 ) {
                            if( node.mAllRight == null ) {
                                insertNodeAll( newNode, node, RIGHT );
                                return ret;
                            } else {
                                node = node.mAllRight;
                            }
                        } else {
                            removeNodeCompletely( node, true );
                            node = mAllRoot;

                            if( node == null ) {
                                insertNodeAll( newNode, null, LEFT );
                                return ret;
                            }
                        }
                    }
                }

            } else {
                Comparable<? super V> comp      = (Comparable<? super V>)value;
                Comparable<? super G> groupComp = (Comparable<? super G>)group;

                while( true ) {
                    int c = comp.compareTo( node.mValue );

                    if( c < 0 ) {
                        if( node.mAllLeft == null ) {
                            insertNodeAll( newNode, node, LEFT );
                            return ret;
                        } else {
                            node = node.mAllLeft;
                        }

                    } else if( c > 0 ) {
                        if( node.mAllRight == null ) {
                            insertNodeAll( newNode, node, RIGHT );
                            return ret;
                        } else {
                            node = node.mAllRight;
                        }
                    } else {
                        G nodeGroup = (G)node.mGroup.mGroup;

                        if( group == null ) {
                            if( nodeGroup == null ) { return ret; }

                            c = -1;
                        } else if( nodeGroup == null ) {
                            c = 1;
                        } else {
                            c = groupComp.compareTo( nodeGroup );
                        }


                        if( c < 0 ) {
                            if( node.mAllLeft == null ) {
                                insertNodeAll( newNode, node, LEFT );
                                return ret;
                            } else {
                                node = node.mAllLeft;
                            }

                        } else if( c > 0 ) {
                            if( node.mAllRight == null ) {
                                insertNodeAll( newNode, node, RIGHT );
                                return ret;
                            } else {
                                node = node.mAllRight;
                            }
                        } else {
                            removeNodeCompletely( node, true );
                            node = mAllRoot;

                            if( node == null ) {
                                insertNodeAll( newNode, null, LEFT );
                                return ret;
                            }
                        }
                    }
                }
            }
        }
    }