def getTopLevelRef(self, node):
        """ Return the top level reference for the passed node """

        node = self.convertToPyNode(node)
        if node.isReferenced():
            fRefObj = FileReference(referenceQuery(node, referenceNode=1), namespace=node.parentNamespace())
            if self.nodeIsNested(node):
                topRefs = getReferences()
                for nSpace, rPath in topRefs.iteritems():
                    fRef = FileReference(referenceQuery(rPath, referenceNode=1), namespace=nSpace)
                    if fRefObj.refNode in fRef.nodes():
                        for g in fRef.nodes():
                            if fRefObj.refNode == g and objExists(g):
                                self.logger.debug('Node reference nested, returning - %s' % fRef.path)
                                return fRef
            else:
                self.logger.debug('Node reference not nested, returning - %s' % fRefObj.path)
                return fRefObj
        else:
            self.logger.debug('Node not referenced, not returning anything')
dataset/ETHPy150Open CountZer0/PipelineConstructionSet/python/maya/core/mayaCore.py/MayaReferenceCore.getTopLevelRef/original