public final void filter(final Object o) throws JSONException {
		if (o instanceof Element) {
			Element element = (Element) o;
			String elemName = element.getName();
			List children = element.getContent();
			List attribute = element.getAttributes();
			Iterator ita = attribute.iterator();
			Iterator itc = children.iterator();

			current++;
			tree.add(current, new JSONObject());

			// Attributes
			while (ita.hasNext()) {
				Object child = ita.next();
				filter(child);
			}
			// Children
			while (itc.hasNext()) {
				Object child = itc.next();
				filter(child);
			}
			handleArray(elemName);
			tree.remove(current);
			current--;
		} else if (o instanceof Attribute) {
			handleAttribute((Attribute) o);
		} else if (o instanceof Text) {
			handleText((Text) o);
		}
	}