Source:
<code>private KTable<K, V> doToTable(final Named named, final MaterializedInternal<K, V, KeyValueStore<Bytes, byte[]>> materializedInternal) { Objects.requireNonNull(named, "named can't be null"); final Serde<K> keySerde = materializedInternal.keySerde() == null ? this.keySerde : materializedInternal.keySerde(); final Serde<V> valueSerde = materializedInternal.valueSerde() == null ? this.valSerde : materializedInternal.valueSerde(); final NamedInternal namedInternal = new NamedInternal(named); final String name = namedInternal.orElseGenerateWithPrefix(builder, TO_KTABLE_NAME); final Set<String> nodes; final StreamsGraphNode nextNode; <START> if (streamsGraphNode.isKeyChangingOperation()) { <END> final OptimizableRepartitionNodeBuilder<K, V> repartitionNodeBuilder = optimizableRepartitionNodeBuilder(); final String sourceName = createRepartitionedSource( builder, keySerde, valueSerde, name, repartitionNodeBuilder ); nextNode = repartitionNodeBuilder.build(); builder.addGraphNode(this.streamsGraphNode, nextNode); nodes = Collections.singleton(sourceName); } else { nextNode = this.streamsGraphNode; nodes = this.sourceNodes; } final KTableSource<K, V> tableSource = new KTableSource<>( materializedInternal.storeName(), materializedInternal.queryableStoreName() ); final ProcessorParameters<K, V> processorParameters = new ProcessorParameters<>(tableSource, name); final StreamsGraphNode tableNode = new StreamToTableNode<>( name, processorParameters, materializedInternal ); builder.addGraphNode(nextNode, tableNode); return new KTableImpl<K, V, V>( name, keySerde, valueSerde, nodes, materializedInternal.queryableStoreName(), tableSource, tableNode, builder ); }</code><technical_language>This verify direct parent -- however, repartitionRequired flag determine if need insert a repartition topic not</technical_language>

Target:
private KTable<K, V> doToTable(final Named named, final MaterializedInternal<K, V, KeyValueStore<Bytes, byte[]>> materializedInternal) { Objects.requireNonNull(named, "named can't be null"); final Serde<K> keySerdeOverride = materializedInternal.keySerde() == null ? keySerde : materializedInternal.keySerde(); final Serde<V> valueSerdeOverride = materializedInternal.valueSerde() == null ? valSerde : materializedInternal.valueSerde(); final NamedInternal namedInternal = new NamedInternal(named); final String name = namedInternal.orElseGenerateWithPrefix(builder, TO_KTABLE_NAME); final Set<String> subTopologySourceNodes; final StreamsGraphNode tableParentNode; if (repartitionRequired) { final OptimizableRepartitionNodeBuilder<K, V> repartitionNodeBuilder = optimizableRepartitionNodeBuilder(); final String sourceName = createRepartitionedSource( builder, keySerdeOverride, valueSerdeOverride, name, repartitionNodeBuilder ); tableParentNode = repartitionNodeBuilder.build(); builder.addGraphNode(streamsGraphNode, tableParentNode); subTopologySourceNodes = Collections.singleton(sourceName); } else { tableParentNode = streamsGraphNode; subTopologySourceNodes = sourceNodes; } final KTableSource<K, V> tableSource = new KTableSource<>( materializedInternal.storeName(), materializedInternal.queryableStoreName() ); final ProcessorParameters<K, V> processorParameters = new ProcessorParameters<>(tableSource, name); final StreamsGraphNode tableNode = new StreamToTableNode<>( name, processorParameters, materializedInternal ); builder.addGraphNode(tableParentNode, tableNode); return new KTableImpl<K, V, V>( name, keySerdeOverride, valueSerdeOverride, subTopologySourceNodes, materializedInternal.queryableStoreName(), tableSource, tableNode, builder ); }