public function removeMapping(PathMapping $mapping)
    {
        if (!$mapping->isLoaded()) {
            throw new NotLoadedException('The passed mapping must be loaded.');
        }

        $moduleName = $mapping->getContainingModule()->getName();

        if (!isset($this->mappings[$moduleName]) || $mapping !== $this->mappings[$moduleName]) {
            return;
        }

        unset($this->mappings[$moduleName]);
        $mapping->removeConflict($this);

        // Conflict was resolved
        if (count($this->mappings) < 2) {
            $resolvedMappings = $this->mappings;
            $this->mappings = array();

            foreach ($resolvedMappings as $resolvedMapping) {
                $resolvedMapping->removeConflict($this);
            }
        }
    }