'Return all available namespaces beginning with expr'

def _namespaces_from_scope(self, expr, scoperef):

    if expr:
        expr = expr.strip('\\')
    namespaces = self._element_names_from_scope_starting_with_expr(expr, scoperef, 'namespace', ('globals', 'imports', 'builtins'), self.namespace_names_from_elem)
    if expr:
        namespace_depth = (expr.count('\\') + 2)
    else:
        namespace_depth = 1
    filtered_namespaces = set()
    for (ilk, n) in namespaces:
        s = n.split('\\')
        filtered_namespaces.add((ilk, '\\'.join(s[:namespace_depth])))
    return list(filtered_namespaces)
