private function find(array &$list, $oid, StockUnitInterface $unit)
    {
        if (!isset($list[$oid])) {
            return false;
        }

        // Non persisted search
        if (null === $unit->getId()) {
            return array_search($unit, $list[$oid], true);
        }

        // Persisted search
        /** @var StockUnitInterface $u */
        foreach ($list[$oid] as $index => $u) {
            if ($u->getId() == $unit->getId()) {
                return $index;
            }
        }

        return false;
    }