@SuppressWarnings ("unchecked")
    public static Class getArrayElementType(Term tq) {
        Quote q = tq.qvalue();
        Stack<Class> st = new Stack<Class>();
        st.push(Object.class);
        for(Term t: q.tokens()) {
            Class c = getJavaType(t);
            if (c.isPrimitive() && !st.peek().isAssignableFrom(c))
                st.push(c);
            else {
                while(st.size() > 0) {
                    Class p = st.peek();
                    if (!p.isAssignableFrom(c))
                        st.pop();
                    else{
                        if (!p.equals(c))
                            st.push(c);
                        break;
                    }
                }
            }
        }
        return st.pop();
    }