'A scoperef is (<blob>, <lpath>). Return the current namespace in
the <blob> ciElementTree, walking up the scope as necessary.'

def _namespace_elem_from_scoperef(self, scoperef):

    (blob, lpath) = scoperef
    if (len(lpath) >= 1):
        elem_chain = []
        elem = blob
        for i in range(len(lpath)):
            try:
                elem = elem.names[lpath[i]]
                elem_chain.append(elem)
            except KeyError:
                break
        for elem in reversed(elem_chain):
            if ((elem.tag == 'scope') and (elem.get('ilk') == 'namespace')):
                return elem
    return None
