class LogicTransformer {

    public GroupElement[] transform( final GroupElement cloned, Map<String, Class<?>> globals ) throws InvalidPatternException {
        //moved cloned to up
        //final GroupElement cloned = (GroupElement) and.clone();

        boolean hasNamedConsequenceAndIsStream = processTree( cloned );
        cloned.pack();

        GroupElement[] ands;
        // is top element an AND?
        if ( cloned.isAnd() ) {
            // Yes, so just return it
            ands = new GroupElement[]{cloned};
        } else if ( cloned.isOr() ) {
            // it is an OR, so each child is an AND branch
            ands = splitOr( cloned );
        } else {
            // no, so just wrap into an AND
            final GroupElement wrapper = GroupElementFactory.newAndInstance();
            wrapper.addChild( cloned );
            ands = new GroupElement[]{wrapper};
        }

        for ( GroupElement and : ands ) {
            // fix the cloned declarations
            this.fixClonedDeclarations( and, globals );
            and.setRoot( true );
        }

        return hasNamedConsequenceAndIsStream ? processNamedConsequences(ands) : ands;
    }

    protected  LogicTransformer();

}