<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_namespace(attribute, namespace_splitter=NAMESPACE_SPLITTER, root_only=False):
 """ Returns given attribute foundations.namespace. Usage:: u'grandParent|parent' u'grandParent' :param attribute: Attribute. :type attribute: unicode :param namespace_splitter: Namespace splitter character. :type namespace_splitter: unicode :param root_only: Return only root foundations.namespace. :type root_only: bool :return: Attribute foundations.namespace. :rtype: unicode """


    attribute_tokens = attribute.split(namespace_splitter)
    if len(attribute_tokens) == 1:
        LOGGER.debug("> Attribute: '{0}', namespace: '{1}'.".format(attribute, Constants.null_object))
    else:
        namespace = foundations.common.get_first_item(attribute_tokens) if root_only else \
            namespace_splitter.join(attribute_tokens[0:-1])
        LOGGER.debug("> Attribute: '{0}', namespace: '{1}'.".format(attribute, namespace))
        return namespace