def getCleanNamespace(namespace):
    """Clean the namespace that is inferred from a directory structure.
       Args:
         namesapce: the namespace
       Returns:
         Clean namespace
    """
    nslevels = namespace.split(".")
    finalLevel = len(nslevels)
    for i in range(len(nslevels) - 1, -1, -1):
        if len(nslevels[i]) > 1:
            finalLevel = i
            break
    return ".".join(nslevels[:(finalLevel + 1)])