{"action":"created","comment":{"url":"https://api.github.com/repos/NataliaDymnikova/CodeU/pulls/comments/119360000","pull_request_review_id":41230209,"id":119360000,"diff_hunk":"@@ -0,0 +1,122 @@\n+import java.util.LinkedList;\n+import java.util.List;\n+\n+/**\n+ * Tree for getting common ancestors\n+ */\n+public class Tree<T> {\n+    private T value;\n+    private Tree<T> parent;\n+    private Tree<T> left;\n+    private Tree<T> right;\n+\n+    Tree(T value) {\n+        this(value, null, null, null);\n+    }\n+\n+    Tree(T value, Tree<T> parent, Tree<T> left, Tree<T> right) {\n+        this.value = value;\n+        this.parent = parent;\n+        this.left = left;\n+        this.right = right;\n+    }\n+\n+    /**\n+     * Add new element\n+     *\n+     * @param newValue  -- new element\n+     * @param parentVal -- value of parent\n+     * @param isLeft    -- is left or right child\n+     * @return true if added\n+     */\n+    boolean add(T newValue, T parentVal, boolean isLeft) {\n+        if (parentVal.equals(value)) {\n+            if (isLeft) {\n+                left = new Tree<T>(newValue, this, left, null);\n+                if (left.left != null) {\n+                    left.left.parent = left;\n+                }\n+            } else {\n+                right = new Tree<T>(newValue, this, null, right);\n+                if (right.right != null) {\n+                    right.right.parent = right;\n+                }\n+            }\n+            return true;\n+        } else {\n+            return (left != null && left.add(newValue, parentVal, isLeft))\n+                    || (right != null && right.add(newValue, parentVal, isLeft));\n+        }\n+    }\n+\n+    /**\n+     *\n+     * Get common ancestor\n+     *\n+     * @param element1 -- first element\n+     * @param element2 -- second element\n+     * @return -- common ancestors for elements\n+     * @throws TreeException.ElementDoesntFound -- if element isn't in tree\n+     * @throws TreeException.NoCommonAncestor -- if one of elements is root\n+     */\n+    T getCommonAncestor(T element1, T element2)\n+            throws TreeException.ElementDoesntFound, TreeException.NoCommonAncestor {\n+        if (value.equals(element1) || value.equals(element2)) {","path":"assignment2/2b/src/Tree.java","position":64,"original_position":64,"commit_id":"eccbc22bcc7f4440ea452e088dd26df48482e859","original_commit_id":"eccbc22bcc7f4440ea452e088dd26df48482e859","user":{"login":"simon-frankau","id":6563758,"avatar_url":"https://avatars2.githubusercontent.com/u/6563758?v=3","gravatar_id":"","url":"https://api.github.com/users/simon-frankau","html_url":"https://github.com/simon-frankau","followers_url":"https://api.github.com/users/simon-frankau/followers","following_url":"https://api.github.com/users/simon-frankau/following{/other_user}","gists_url":"https://api.github.com/users/simon-frankau/gists{/gist_id}","starred_url":"https://api.github.com/users/simon-frankau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simon-frankau/subscriptions","organizations_url":"https://api.github.com/users/simon-frankau/orgs","repos_url":"https://api.github.com/users/simon-frankau/repos","events_url":"https://api.github.com/users/simon-frankau/events{/privacy}","received_events_url":"https://api.github.com/users/simon-frankau/received_events","type":"User","site_admin":false},"body":"Nodes are considered ancestors of themselves (see Slack), so if both elements are present then there will always be a common ancestor - at worst, the root node.","created_at":"2017-05-31T13:51:52Z","updated_at":"2017-05-31T14:03:22Z","html_url":"https://github.com/NataliaDymnikova/CodeU/pull/3#discussion_r119360000","pull_request_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/NataliaDymnikova/CodeU/pulls/comments/119360000"},"html":{"href":"https://github.com/NataliaDymnikova/CodeU/pull/3#discussion_r119360000"},"pull_request":{"href":"https://api.github.com/repos/NataliaDymnikova/CodeU/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/NataliaDymnikova/CodeU/pulls/3","id":122433977,"html_url":"https://github.com/NataliaDymnikova/CodeU/pull/3","diff_url":"https://github.com/NataliaDymnikova/CodeU/pull/3.diff","patch_url":"https://github.com/NataliaDymnikova/CodeU/pull/3.patch","issue_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/issues/3","number":3,"state":"open","locked":false,"title":"Second task","user":{"login":"NataliaDymnikova","id":8722242,"avatar_url":"https://avatars0.githubusercontent.com/u/8722242?v=3","gravatar_id":"","url":"https://api.github.com/users/NataliaDymnikova","html_url":"https://github.com/NataliaDymnikova","followers_url":"https://api.github.com/users/NataliaDymnikova/followers","following_url":"https://api.github.com/users/NataliaDymnikova/following{/other_user}","gists_url":"https://api.github.com/users/NataliaDymnikova/gists{/gist_id}","starred_url":"https://api.github.com/users/NataliaDymnikova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NataliaDymnikova/subscriptions","organizations_url":"https://api.github.com/users/NataliaDymnikova/orgs","repos_url":"https://api.github.com/users/NataliaDymnikova/repos","events_url":"https://api.github.com/users/NataliaDymnikova/events{/privacy}","received_events_url":"https://api.github.com/users/NataliaDymnikova/received_events","type":"User","site_admin":false},"body":"Second assignment","created_at":"2017-05-25T12:52:27Z","updated_at":"2017-05-31T14:03:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cef2cc794c7ad26c059c0755d2aa85f922960712","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/pulls/3/commits","review_comments_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/pulls/3/comments","review_comment_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/pulls/comments{/number}","comments_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/issues/3/comments","statuses_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/statuses/eccbc22bcc7f4440ea452e088dd26df48482e859","head":{"label":"NataliaDymnikova:second-task","ref":"second-task","sha":"eccbc22bcc7f4440ea452e088dd26df48482e859","user":{"login":"NataliaDymnikova","id":8722242,"avatar_url":"https://avatars0.githubusercontent.com/u/8722242?v=3","gravatar_id":"","url":"https://api.github.com/users/NataliaDymnikova","html_url":"https://github.com/NataliaDymnikova","followers_url":"https://api.github.com/users/NataliaDymnikova/followers","following_url":"https://api.github.com/users/NataliaDymnikova/following{/other_user}","gists_url":"https://api.github.com/users/NataliaDymnikova/gists{/gist_id}","starred_url":"https://api.github.com/users/NataliaDymnikova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NataliaDymnikova/subscriptions","organizations_url":"https://api.github.com/users/NataliaDymnikova/orgs","repos_url":"https://api.github.com/users/NataliaDymnikova/repos","events_url":"https://api.github.com/users/NataliaDymnikova/events{/privacy}","received_events_url":"https://api.github.com/users/NataliaDymnikova/received_events","type":"User","site_admin":false},"repo":{"id":91589068,"name":"CodeU","full_name":"NataliaDymnikova/CodeU","owner":{"login":"NataliaDymnikova","id":8722242,"avatar_url":"https://avatars0.githubusercontent.com/u/8722242?v=3","gravatar_id":"","url":"https://api.github.com/users/NataliaDymnikova","html_url":"https://github.com/NataliaDymnikova","followers_url":"https://api.github.com/users/NataliaDymnikova/followers","following_url":"https://api.github.com/users/NataliaDymnikova/following{/other_user}","gists_url":"https://api.github.com/users/NataliaDymnikova/gists{/gist_id}","starred_url":"https://api.github.com/users/NataliaDymnikova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NataliaDymnikova/subscriptions","organizations_url":"https://api.github.com/users/NataliaDymnikova/orgs","repos_url":"https://api.github.com/users/NataliaDymnikova/repos","events_url":"https://api.github.com/users/NataliaDymnikova/events{/privacy}","received_events_url":"https://api.github.com/users/NataliaDymnikova/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/NataliaDymnikova/CodeU","description":null,"fork":false,"url":"https://api.github.com/repos/NataliaDymnikova/CodeU","forks_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/forks","keys_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/teams","hooks_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/hooks","issue_events_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/issues/events{/number}","events_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/events","assignees_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/assignees{/user}","branches_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/branches{/branch}","tags_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/tags","blobs_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/git/refs{/sha}","trees_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/statuses/{sha}","languages_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/languages","stargazers_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/stargazers","contributors_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/contributors","subscribers_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/subscribers","subscription_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/subscription","commits_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/commits{/sha}","git_commits_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/git/commits{/sha}","comments_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/comments{/number}","issue_comment_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/issues/comments{/number}","contents_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/contents/{+path}","compare_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/merges","archive_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/downloads","issues_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/issues{/number}","pulls_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/pulls{/number}","milestones_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/milestones{/number}","notifications_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/labels{/name}","releases_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/releases{/id}","deployments_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/deployments","created_at":"2017-05-17T14:59:20Z","updated_at":"2017-05-17T15:24:48Z","pushed_at":"2017-05-31T09:34:55Z","git_url":"git://github.com/NataliaDymnikova/CodeU.git","ssh_url":"git@github.com:NataliaDymnikova/CodeU.git","clone_url":"https://github.com/NataliaDymnikova/CodeU.git","svn_url":"https://github.com/NataliaDymnikova/CodeU","homepage":null,"size":13,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"NataliaDymnikova:master","ref":"master","sha":"1334b0f6d4d89d0fb1e74c5da05299fda1f5a641","user":{"login":"NataliaDymnikova","id":8722242,"avatar_url":"https://avatars0.githubusercontent.com/u/8722242?v=3","gravatar_id":"","url":"https://api.github.com/users/NataliaDymnikova","html_url":"https://github.com/NataliaDymnikova","followers_url":"https://api.github.com/users/NataliaDymnikova/followers","following_url":"https://api.github.com/users/NataliaDymnikova/following{/other_user}","gists_url":"https://api.github.com/users/NataliaDymnikova/gists{/gist_id}","starred_url":"https://api.github.com/users/NataliaDymnikova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NataliaDymnikova/subscriptions","organizations_url":"https://api.github.com/users/NataliaDymnikova/orgs","repos_url":"https://api.github.com/users/NataliaDymnikova/repos","events_url":"https://api.github.com/users/NataliaDymnikova/events{/privacy}","received_events_url":"https://api.github.com/users/NataliaDymnikova/received_events","type":"User","site_admin":false},"repo":{"id":91589068,"name":"CodeU","full_name":"NataliaDymnikova/CodeU","owner":{"login":"NataliaDymnikova","id":8722242,"avatar_url":"https://avatars0.githubusercontent.com/u/8722242?v=3","gravatar_id":"","url":"https://api.github.com/users/NataliaDymnikova","html_url":"https://github.com/NataliaDymnikova","followers_url":"https://api.github.com/users/NataliaDymnikova/followers","following_url":"https://api.github.com/users/NataliaDymnikova/following{/other_user}","gists_url":"https://api.github.com/users/NataliaDymnikova/gists{/gist_id}","starred_url":"https://api.github.com/users/NataliaDymnikova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NataliaDymnikova/subscriptions","organizations_url":"https://api.github.com/users/NataliaDymnikova/orgs","repos_url":"https://api.github.com/users/NataliaDymnikova/repos","events_url":"https://api.github.com/users/NataliaDymnikova/events{/privacy}","received_events_url":"https://api.github.com/users/NataliaDymnikova/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/NataliaDymnikova/CodeU","description":null,"fork":false,"url":"https://api.github.com/repos/NataliaDymnikova/CodeU","forks_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/forks","keys_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/teams","hooks_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/hooks","issue_events_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/issues/events{/number}","events_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/events","assignees_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/assignees{/user}","branches_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/branches{/branch}","tags_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/tags","blobs_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/git/refs{/sha}","trees_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/statuses/{sha}","languages_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/languages","stargazers_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/stargazers","contributors_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/contributors","subscribers_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/subscribers","subscription_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/subscription","commits_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/commits{/sha}","git_commits_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/git/commits{/sha}","comments_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/comments{/number}","issue_comment_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/issues/comments{/number}","contents_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/contents/{+path}","compare_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/merges","archive_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/downloads","issues_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/issues{/number}","pulls_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/pulls{/number}","milestones_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/milestones{/number}","notifications_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/labels{/name}","releases_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/releases{/id}","deployments_url":"https://api.github.com/repos/NataliaDymnikova/CodeU/deployments","created_at":"2017-05-17T14:59:20Z","updated_at":"2017-05-17T15:24:48Z","pushed_at":"2017-05-31T09:34:55Z","git_url":"git://github.com/NataliaDymnikova/CodeU.git","ssh_url":"git@github.com:NataliaDymnikova/CodeU.git","clone_url":"https://github.com/NataliaDymnikova/CodeU.git","svn_url":"https://github.com/NataliaDymnikova/CodeU","homepage":null,"size":13,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/NataliaDymnikova/CodeU/pulls/3"},"html":{"href":"https://github.com/NataliaDymnikova/CodeU/pull/3"},"issue":{"href":"https://api.github.com/repos/NataliaDymnikova/CodeU/issues/3"},"comments":{"href":"https://api.github.com/repos/NataliaDymnikova/CodeU/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/NataliaDymnikova/CodeU/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/NataliaDymnikova/CodeU/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/NataliaDymnikova/CodeU/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/NataliaDymnikova/CodeU/statuses/eccbc22bcc7f4440ea452e088dd26df48482e859"}}}}
{"actor":{"display_login":"simon-frankau"}}