Removing an item from a list of library files added to a command object

If library file objects are added to a command object, attempting to remove any that are specified as "real path" item objects fails as shown.

function OnClick(clickData)
{
	// --------------------------------------------------------
	var cmd = clickData.func.command;
	cmd.deselect = false; // Prevent automatic deselection
	// --------------------------------------------------------
	var f = clickData.func.sourcetab.files(0); // First file in a library folder
	DOpus.output(f); // Display its "library" name
	var itm = f.realpath; // Determine its real path
	DOpus.output(itm); // Display its real path
	cmd.addfiles(clickData.func.sourcetab.files); // Add all files in the library folder to a command object
	cmd.removefile(itm); // Attempt to remove one using its real path
	return;
	// --------------------------------------------------------
}

You'd need to remove the path that's in the command object, not another alias for the same file/folder.