Speed up by short circuiting compose_edges if a node's subtree has already been composed