return expiration of contract / "multi" contract's contracts

def getExpirations(self, contract_identifier, expired=0):
        """ return expiration of contract / "multi" contract's contracts """
        expirations = []
        contracts = self.contractDetails(contract_identifier)["contracts"]

        if contracts[0].m_secType not in ("FUT", "FOP", "OPT"):
            return []

        # collect expirations
        for contract in contracts:
            expirations.append(contract.m_expiry)

        # convert to ints
        expirations = list(map(int, expirations))
        # expirations = list(set(expirations))

        # remove expired contracts
        today = int(datetime.now().strftime("%Y%m%d"))
        closest = min(expirations, key=lambda x: abs(x - today))
        expirations = expirations[expirations.index(closest) - expired:]

        return tuple(expirations)