}
private void printOrphanCommentsBeforeThisChildNode(final Node node){
if (node instanceof Comment) return;
Node parent = node.getParentNode();
if (parent==null) return;
List<Node> everything = new LinkedList<Node>();
everything.addAll(parent.getChildrenNodes());
sortByBeginPosition(everything);
int positionOfTheChild = -1;
for (int i=0;i<everything.size();i++){
if (everything.get(i)==node) positionOfTheChild=i;
}
if (positionOfTheChild==-1) throw new RuntimeException("My index not found!!! "+node);
int positionOfPreviousChild = -1;
for (int i=positionOfTheChild-1;i>=0 && positionOfPreviousChild==-1;i--){
if (!(everything.get(i) instanceof Comment)) positionOfPreviousChild = i;
}
for (int i=positionOfPreviousChild+1;i<positionOfTheChild;i++){
Node nodeToPrint = everything.get(i);
if (!(nodeToPrint instanceof Comment)) throw new RuntimeException("Expected comment, instead "+nodeToPrint.getClass()+". Position of previous child: "+positionOfPreviousChild+", position of child "+positionOfTheChild);
nodeToPrint.accept(this,null);
}
}