int (ASTNode root, ASTNode child) { if (child == root) return 0; ASTNode parent = child.getTreeParent(); int offset = 0; for (ASTNode child1 = parent.getFirstChildNode(); child1 != child; child1 = child1.getTreeNext()) { offset += child1.getTextLength(); } return getStartOffset(root, parent) + offset; }