public static SyntacticItem substitute(SyntacticItem item, SyntacticItem from, SyntacticItem to) {
    """
	<p>
	Create a new syntactic item by replacing all occurrences of one item
	(<code>from</code>) with another (<code>to</code>). In the case that
	there is no change to the item (or any of its children) then the original
	item is returned untouched. Specifically, the exact same reference will
	be returned.
	</p>
	<p>
	Any new items created during this process are allocated into the heap of
	the item they are replacing. This is necessary since otherwise a mix of
	allocated and unallocated items would be returned, making it difficult to
	then allocate them all.
	</p>
	<p>
	This method preserves the underlying aliasing structure of the object
	being cloned. However, aliasing information is not preserved across calls
	to this method. Furthermore, it is not currently capable of handling
	cyclic structures.
	</p>
	
	@param item
	The syntactic item we are currently substituting into
	@param from
	The syntactic item we are looking to replace
	@param to
	The syntactic item that will replace all occurrences of from
	@return
    """
		SyntacticItem nItem = substitute(item, from, to, new IdentityHashMap<>());
		if(nItem != item) {
			item.getHeap().allocate(nItem);
		}
		return nItem;
	}
public static SyntacticItem substitute(SyntacticItem item, SyntacticItem from, SyntacticItem to) {
		SyntacticItem nItem = substitute(item, from, to, new IdentityHashMap<>());
		if(nItem != item) {
			item.getHeap().allocate(nItem);
		}
		return nItem;
	}
public static SyntacticItem substitute ( SyntacticItem item , SyntacticItem from , SyntacticItem to ) { SyntacticItem nItem = substitute ( item , from , to , new IdentityHashMap <> ( ) ) ; if ( nItem != item ) { item . getHeap ( ) . allocate ( nItem ) ; } return nItem ; }
<p>
Create a new syntactic item by replacing all occurrences of one item
(<code>from</code>) with another (<code>to</code>). In the case that
there is no change to the item (or any of its children) then the original
item is returned untouched. Specifically, the exact same reference will
be returned.
</p>
<p>
Any new items created during this process are allocated into the heap of
the item they are replacing. This is necessary since otherwise a mix of
allocated and unallocated items would be returned, making it difficult to
then allocate them all.
</p>
<p>
This method preserves the underlying aliasing structure of the object
being cloned. However, aliasing information is not preserved across calls
to this method. Furthermore, it is not currently capable of handling
cyclic structures.
</p>

@param item
The syntactic item we are currently substituting into
@param from
The syntactic item we are looking to replace
@param to
The syntactic item that will replace all occurrences of from
@return
<p > Create a new syntactic item by replacing all occurrences of one item ( <code > from< / code > ) with another ( <code > to< / code > ) . In the case that there is no change to the item ( or any of its children ) then the original item is returned untouched . Specifically the exact same reference will be returned . < / p > <p > Any new items created during this process are allocated into the heap of the item they are replacing . This is necessary since otherwise a mix of allocated and unallocated items would be returned making it difficult to then allocate them all . < / p > <p > This method preserves the underlying aliasing structure of the object being cloned . However aliasing information is not preserved across calls to this method . Furthermore it is not currently capable of handling cyclic structures . < / p >