public function saveGeneratedHierarchy( $filename, $zip = false )
	{
		$result = true;

		if ( ! property_exists( $this, 'hierarchies' ) ) return "The hierarchies have not been generated";
		$json = json_encode( $this->hierarchies );
		if ( json_last_error() !== JSON_ERROR_NONE )
		{
			$result = "An error occurred generating the JSON for the hierarchies: " . XBRL::json_last_error_msg();
		}
		elseif ( $zip )
		{
			$zip = new ZipArchive();
			$zip->open( $filename, ZipArchive::CREATE );
			if ( ! $zip->addFromString( 'hierarchies.json', $json ) )
			{
				$result = "Failed to add JSON to zip file";
			}

			if ( $zip->close() === false )
			{
				$result = "Error closing zip file: " . $zip->getStatusString();
			}
		}
		else
		{
			if ( file_put_contents( $filename, $json ) === false )
			{
				$result = "Writing to the file failed";
			}
		}

		return $result;
	}