private function _store_licenses( $store = true, $module_id = false, $licenses = array() ) {
            $this->_logger->entrance();

            $all_licenses = self::get_all_licenses();

            if ( ! FS_Plugin::is_valid_id( $module_id ) ) {
                $module_id = $this->_module_id;

                $user_licenses = is_array( $this->_licenses ) ?
                    $this->_licenses :
                    array();

                if ( empty( $user_licenses ) ) {
                    // If the context user doesn't have any license, don't update the licenses collection.
                    return;
                }

                $new_user_licenses_map = array();
                foreach ( $user_licenses as $user_license ) {
                    $new_user_licenses_map[ $user_license->id ] = $user_license;
                }

                self::store_user_id_license_ids_map( array_keys( $new_user_licenses_map ), $this->_module_id, $this->_user->id );

                // Update user licenses.
                $licenses_to_update_count = count( $new_user_licenses_map );
                foreach ( $all_licenses[ $module_id ] as $key => $license ) {
                    if ( 0 === $licenses_to_update_count ) {
                        break;
                    }

                    if ( isset( $new_user_licenses_map[ $license->id ] ) ) {
                        // Update license.
                        $all_licenses[ $module_id ][ $key ] = $new_user_licenses_map[ $license->id ];
                        unset( $new_user_licenses_map[ $license->id ] );

                        $licenses_to_update_count --;
                    }
                }

                if ( ! empty( $new_user_licenses_map ) ) {
                    // Add new licenses.
                    $all_licenses[ $module_id ] = array_merge( array_values( $new_user_licenses_map ), $all_licenses[ $module_id ] );
                }

                $licenses = $all_licenses[ $module_id ];
            }

            if ( ! isset( $all_licenses[ $module_id ] ) ) {
                $all_licenses[ $module_id ] = array();
            }

            $all_licenses[ $module_id ] = $licenses;

            self::$_accounts->set_option( 'all_licenses', $all_licenses, $store );
        }