private static @Nullable ASTNode getNextOrPrevious(@Nullable ASTNode node, boolean isNext, IElementType @NotNull ... typesToIgnore) {
    if (node == null) return null;

    ASTNode each = isNext ? node.getTreeNext() : node.getTreePrev();
    ASTNode parent = node.getTreeParent();
    while (each == null && parent != null) {
      each = isNext ? parent.getTreeNext() : parent.getTreePrev();
      parent = parent.getTreeParent();
    }

    if (each == null) {
      return null;
    }

    if (ArrayUtil.contains(each.getElementType(), typesToIgnore)) {
      return getNextOrPrevious(each, isNext, typesToIgnore);
    }

    return each;
  }
private static @Nullable ASTNode getNextOrPrevious(@Nullable ASTNode node, boolean isNext, IElementType @NotNull ... typesToIgnore)