{"action":"opened","issue":{"url":"https://api.github.com/repos/caesar0301/treelib/issues/47","labels_url":"https://api.github.com/repos/caesar0301/treelib/issues/47/labels{/name}","comments_url":"https://api.github.com/repos/caesar0301/treelib/issues/47/comments","events_url":"https://api.github.com/repos/caesar0301/treelib/issues/47/events","html_url":"https://github.com/caesar0301/treelib/issues/47","id":99209395,"number":47,"title":"Serious issue with subtrees!","user":{"login":"fpug","id":10880567,"avatar_url":"https://avatars.githubusercontent.com/u/10880567?v=3","gravatar_id":"","url":"https://api.github.com/users/fpug","html_url":"https://github.com/fpug","followers_url":"https://api.github.com/users/fpug/followers","following_url":"https://api.github.com/users/fpug/following{/other_user}","gists_url":"https://api.github.com/users/fpug/gists{/gist_id}","starred_url":"https://api.github.com/users/fpug/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fpug/subscriptions","organizations_url":"https://api.github.com/users/fpug/orgs","repos_url":"https://api.github.com/users/fpug/repos","events_url":"https://api.github.com/users/fpug/events{/privacy}","received_events_url":"https://api.github.com/users/fpug/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-08-05T13:53:34Z","updated_at":"2015-08-05T13:53:34Z","closed_at":null,"body":"Hi guys,\r\n\r\nI was trying your library out, it looks great.\r\nYet I believe there is a design issue with how you implemented the subtrees.  Right now a tree is defined by a dictionary of nodes and the id of the root node, the hierarchy being expressed in the bpointer and fpointer of the individual node instances.\r\n\r\nWhat happens when I create a subtree?  A new tree object is created, that has a subset of the nodes of the original tree.  As you mention the copy is shallow, so the nodes themselves are not deep copied. This is useful, because in principle it allows to operate on the subtrees influencing the structure of the main tree, and vice-versa.\r\n\r\nBut what if I first create a subtree out of a tree, then add a node either to this subtree or to the original tree?  What happens is that the fpointers and bpointers of the nodes in question will be updated to include the new node, but *just the nodes dictionary of either the tree or subtree will be updated*.\r\n\r\nSo when for example the function _print_backend(...) gets invoked on the tree if I modified the subtree, or on the subtree if I modified the tree, it will throw an error at the line:\r\n\r\n```python\r\nqueue = [self[i] for i in self[nid].fpointer if filter(self[i])]\r\n ```\r\nbecause there will be identifiers that are in the list of fpointers but NOT in the nodes of the tree/subtree.  \r\n\r\nHow would you go about fixing that?\r\n\r\nHave a great day and thanks,\r\n\r\nFrancesco"}}