Returns the urn up to given level using URN Constants

        :param key: Identifier of the wished resource using URN constants
        :type key: int
        :returns: String representation of the partial URN requested
        :rtype: str

        :Example:
            >>>    a = URN(urn="urn:cts:latinLit:phi1294.phi002.perseus-lat2:1.1")
            >>>    a.upTo(URN.TEXTGROUP) == "urn:cts:latinLit:phi1294"

def upTo(self, key):
        """ Returns the urn up to given level using URN Constants

        :param key: Identifier of the wished resource using URN constants
        :type key: int
        :returns: String representation of the partial URN requested
        :rtype: str

        :Example:
            >>>    a = URN(urn="urn:cts:latinLit:phi1294.phi002.perseus-lat2:1.1")
            >>>    a.upTo(URN.TEXTGROUP) == "urn:cts:latinLit:phi1294"
        """
        middle = [
            component
            for component in [self.__parsed["textgroup"], self.__parsed["work"], self.__parsed["version"]]
            if component is not None
        ]

        if key == URN.COMPLETE:
            return self.__str__()
        elif key == URN.NAMESPACE:
            return ":".join([
                "urn",
                self.__parsed["urn_namespace"],
                self.__parsed["cts_namespace"]])
        elif key == URN.TEXTGROUP and self.__parsed["textgroup"]:
            return ":".join([
                "urn",
                self.__parsed["urn_namespace"],
                self.__parsed["cts_namespace"],
                self.__parsed["textgroup"]
            ])
        elif key == URN.WORK and self.__parsed["work"]:
            return ":".join([
                "urn",
                self.__parsed["urn_namespace"],
                self.__parsed["cts_namespace"],
                ".".join([self.__parsed["textgroup"], self.__parsed["work"]])
            ])
        elif key == URN.VERSION and self.__parsed["version"]:
            return ":".join([
                "urn",
                self.__parsed["urn_namespace"],
                self.__parsed["cts_namespace"],
                ".".join(middle)
            ])
        elif key == URN.NO_PASSAGE and self.__parsed["work"]:
            return ":".join([
                "urn",
                self.__parsed["urn_namespace"],
                self.__parsed["cts_namespace"],
                ".".join(middle)
            ])
        elif key == URN.PASSAGE and self.__parsed["reference"]:
            return ":".join([
                "urn",
                self.__parsed["urn_namespace"],
                self.__parsed["cts_namespace"],
                ".".join(middle),
                str(self.reference)
            ])
        elif key == URN.PASSAGE_START and self.__parsed["reference"]:
            return ":".join([
                "urn",
                self.__parsed["urn_namespace"],
                self.__parsed["cts_namespace"],
                ".".join(middle),
                str(self.reference.start)
            ])
        elif key == URN.PASSAGE_END and self.__parsed["reference"] and self.reference.end is not None:
            return ":".join([
                "urn",
                self.__parsed["urn_namespace"],
                self.__parsed["cts_namespace"],
                ".".join(middle),
                str(self.reference.end)
            ])
        else:
            raise KeyError("Provided key is not recognized.")