@Override
    public IQTree convertTree(IntermediateQuery query, QueryNode rootNode) {
        if (rootNode instanceof LeafIQTree) {
            return (LeafIQTree) rootNode;
        }
        else if (rootNode instanceof UnaryOperatorNode) {
            // Recursive
            IQTree childTree = convertTree(query, query.getFirstChild(rootNode).get());
            return iqFactory.createUnaryIQTree((UnaryOperatorNode) rootNode, childTree);
        }
        else if (rootNode instanceof BinaryNonCommutativeOperatorNode) {
            IQTree leftChildTree = convertTree(query, query.getChild(rootNode, LEFT).get());
            IQTree rightChildTree = convertTree(query, query.getChild(rootNode, RIGHT).get());

            return iqFactory.createBinaryNonCommutativeIQTree((BinaryNonCommutativeOperatorNode) rootNode,
                    leftChildTree, rightChildTree);
        }
        else if (rootNode instanceof NaryOperatorNode) {
            ImmutableList<IQTree> childTrees = query.getChildren(rootNode).stream()
                    .map(c -> convertTree(query, c))
                    .collect(ImmutableCollectors.toList());

            return iqFactory.createNaryIQTree((NaryOperatorNode) rootNode, childTrees);
        }

        throw new MinorOntopInternalBugException("Unexpected type of query node: " + rootNode);
    }
@ Override public IQTree convertTree ( IntermediateQuery query , QueryNode rootNode ) { if ( rootNode instanceof LeafIQTree ) { return ( LeafIQTree ) rootNode ; } else if ( rootNode instanceof UnaryOperatorNode ) { IQTree childTree = convertTree ( query , query . getFirstChild ( rootNode ) . get ( ) ) ; return iqFactory . createUnaryIQTree ( ( UnaryOperatorNode ) rootNode , childTree ) ; } else if ( rootNode instanceof BinaryNonCommutativeOperatorNode ) { IQTree leftChildTree = convertTree ( query , query . getChild ( rootNode , LEFT ) . get ( ) ) ; IQTree rightChildTree = convertTree ( query , query . getChild ( rootNode , RIGHT ) . get ( ) ) ; return iqFactory . createBinaryNonCommutativeIQTree ( ( BinaryNonCommutativeOperatorNode ) rootNode , leftChildTree , rightChildTree ) ; } else if ( rootNode instanceof NaryOperatorNode ) { ImmutableList < IQTree > childTrees = query . getChildren ( rootNode ) . stream ( ) . map ( c -> convertTree ( query , c ) ) . collect ( ImmutableCollectors . toList ( ) ) ; return iqFactory . createNaryIQTree ( ( NaryOperatorNode ) rootNode , childTrees ) ; } throw new MinorOntopInternalBugException ( "Unexpected type of query node: " + rootNode ) ; }
Recursive