(tree)
return groups, nodes, body
Given a tree element, recursively separate that AST into lists of ASTs for the
        subgroups, nodes, and body. This is an intermediate step to allow for
        clearner processing downstream

        :param tree ast:
        :returns: tuple of group, node, and body trees. These are processed
                  downstream into real Groups and Nodes.
        :rtype: (list[ast], list[ast], list[ast])
Given a tree element, recursively separate that AST into lists of ASTs for the
        subgroups, nodes, and body. This is an intermediate step to allow for
        clearner processing downstream
Given a tree element recursively separate that AST into lists of ASTs for the subgroups nodes and body . This is an intermediate step to allow for clearner processing downstream
def separate_namespaces(tree):
        """
        Given a tree element, recursively separate that AST into lists of ASTs for the
        subgroups, nodes, and body. This is an intermediate step to allow for
        clearner processing downstream

        :param tree ast:
        :returns: tuple of group, node, and body trees. These are processed
                  downstream into real Groups and Nodes.
        :rtype: (list[ast], list[ast], list[ast])
        """
        tree = tree or []  # if its abstract, it comes in with no body

        groups = []
        nodes = []
        body = []
        for el in tree:
            if el['nodeType'] in ('Stmt_Function', 'Stmt_ClassMethod', 'Expr_Closure'):
                nodes.append(el)
            elif el['nodeType'] in ('Stmt_Class', 'Stmt_Namespace', 'Stmt_Trait'):
                groups.append(el)
            else:
                tup = PHP.separate_namespaces(children(el))
                if tup[0] or tup[1]:
                    groups += tup[0]
                    nodes += tup[1]
                    body += tup[2]
                else:
                    body.append(el)
        return groups, nodes, body
def separate_namespaces ( tree ) : tree = tree or [ ] # if its abstract, it comes in with no body groups = [ ] nodes = [ ] body = [ ] for el in tree : if el [ 'nodeType' ] in ( 'Stmt_Function' , 'Stmt_ClassMethod' , 'Expr_Closure' ) : nodes . append ( el ) elif el [ 'nodeType' ] in ( 'Stmt_Class' , 'Stmt_Namespace' , 'Stmt_Trait' ) : groups . append ( el ) else : tup = PHP . separate_namespaces ( children ( el ) ) if tup [ 0 ] or tup [ 1 ] : groups += tup [ 0 ] nodes += tup [ 1 ] body += tup [ 2 ] else : body . append ( el ) return groups , nodes , body