public static void removeLastChild(Element tag){
  final Node last=tag.getLastChild();
  if (last != null) {
    tag.removeChild(last);
  }
}

public static void removeLastChild ( Element tag ) { final Node last = tag . getLastChild ( ) ; if ( last != null ) { tag . removeChild ( last ) ; } }
remove last child of an element , when present
