@Override
    public boolean contains(long element) {
        if (layout.length == 0) {
            return false;
        }
        int currentPos = 0;
        while (currentPos >= 0) {
            int rightChildPointer = getRightChildPointer(currentPos);
            int leftChildPointer = getLeftChildPointer(currentPos);
            if (rightChildPointer == -2) {
                currentPos = leftChildPointer;
                continue;
            }
            long candidate = getValue(currentPos);
            if (candidate == element) {
                return true;
            }
            if (element < candidate) {
                currentPos = leftChildPointer;
            } else {
                currentPos = rightChildPointer;
            }
        }
        return false;
    }