public function findByDirectory(Dir $directoryInPackage) {
    foreach ($this->packages as $package) {
      if ($directoryInPackage->isSubdirectoryOf($package->getRootDirectory())
          || $directoryInPackage->equals($package->getRootDirectory())
         ) {
        return $package;
      }
    }
  }