def getName(self):
if self.__name:<EOL><INDENT>return self.__name<EOL><DEDENT>elif self.__parent:<EOL><INDENT>par = self.__parent()<EOL>if par:<EOL><INDENT>return par.__lookup(self)<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT><DEDENT>elif (len(self) == <NUM_LIT:1> and<EOL>len(self.__tokdict) == <NUM_LIT:1> and<EOL>next(iter(self.__tokdict.values()))[<NUM_LIT:0>][<NUM_LIT:1>] in (<NUM_LIT:0>,-<NUM_LIT:1>)):<EOL><INDENT>return next(iter(self.__tokdict.keys()))<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>
r"""
        Returns the results name for this token expression. Useful when several
        different expressions might match at a particular location.

        Example::

            integer = Word(nums)
            ssn_expr = Regex(r"\d\d\d-\d\d-\d\d\d\d")
            house_number_expr = Suppress('#') + Word(nums, alphanums)
            user_data = (Group(house_number_expr)("house_number")
                        | Group(ssn_expr)("ssn")
                        | Group(integer)("age"))
            user_info = OneOrMore(user_data)

            result = user_info.parseString("22 111-22-3333 #221B")
            for item in result:
                print(item.getName(), ':', item[0])

        prints::

            age : 22
            ssn : 111-22-3333
            house_number : 221B