private static ASTNode getLastNonSpaceChild(@NotNull ASTNode node, boolean acceptError) {
    ASTNode lastChild = node.getLastChildNode();
    while (lastChild != null &&
           (lastChild.getElementType() == TokenType.WHITE_SPACE || (!acceptError && lastChild.getPsi() instanceof PsiErrorElement))) {
      lastChild = lastChild.getTreePrev();
    }
    return lastChild;
  }
private static ASTNode getLastNonSpaceChild(@NotNull ASTNode node, boolean acceptError)